From 596b110e1863958f9d36a5581c0c30560e3dff91 Mon Sep 17 00:00:00 2001 From: Philip Bauer Date: Sun, 1 Apr 2018 12:45:14 +0200 Subject: [PATCH 1/6] fix init in py3 --- plone/schemaeditor/browser/schema/traversal.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plone/schemaeditor/browser/schema/traversal.py b/plone/schemaeditor/browser/schema/traversal.py index effefff..666fb78 100644 --- a/plone/schemaeditor/browser/schema/traversal.py +++ b/plone/schemaeditor/browser/schema/traversal.py @@ -6,6 +6,8 @@ from zope.publisher.interfaces.browser import IBrowserPublisher from ZPublisher.BaseRequest import DefaultPublishTraverse +import six + @implementer(ISchemaContext, IBrowserPublisher) class SchemaContext(SimpleItem): @@ -21,7 +23,10 @@ class SchemaContext(SimpleItem): enableFieldsets = True def __init__(self, context, request, name=u'schema', title=None): - super(SchemaContext, self).__init__(context, request) + if six.PY2: + super(SchemaContext, self).__init__(context, request) + else: + super().__init__() self.schema = context self.request = request From b1c3e6fdd0188bea4df85eb74da8a78767121c3a Mon Sep 17 00:00:00 2001 From: Philip Bauer Date: Wed, 16 May 2018 18:28:36 +0200 Subject: [PATCH 2/6] remove obsolete and broken object.__init__() --- plone/schemaeditor/browser/schema/traversal.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plone/schemaeditor/browser/schema/traversal.py b/plone/schemaeditor/browser/schema/traversal.py index 666fb78..ebf87a5 100644 --- a/plone/schemaeditor/browser/schema/traversal.py +++ b/plone/schemaeditor/browser/schema/traversal.py @@ -23,10 +23,6 @@ class SchemaContext(SimpleItem): enableFieldsets = True def __init__(self, context, request, name=u'schema', title=None): - if six.PY2: - super(SchemaContext, self).__init__(context, request) - else: - super().__init__() self.schema = context self.request = request From 28174f5153c842f747a17a8404e3f501bad7ad99 Mon Sep 17 00:00:00 2001 From: Philip Bauer Date: Mon, 11 Jun 2018 08:24:27 +0200 Subject: [PATCH 3/6] prevent dictionary changed size during iteration in py3 --- plone/schemaeditor/browser/schema/add_field.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plone/schemaeditor/browser/schema/add_field.py b/plone/schemaeditor/browser/schema/add_field.py index bcaff20..679f2ea 100644 --- a/plone/schemaeditor/browser/schema/add_field.py +++ b/plone/schemaeditor/browser/schema/add_field.py @@ -46,7 +46,7 @@ def create(self, data): factory = data.pop('factory') # split regular attributes and extra ones - for key in data.keys(): + for key in list(data.keys()): if key not in self._schema: extra[key] = data[key] data.pop(key) From 4e008cba10035c65f6c1207da0b27891033ee564 Mon Sep 17 00:00:00 2001 From: Philip Bauer Date: Thu, 14 Jun 2018 23:56:37 +0200 Subject: [PATCH 4/6] fix tests --- plone/schemaeditor/tests/choice.rst | 8 ++++---- plone/schemaeditor/tests/editing.rst | 20 ++++++++++---------- plone/schemaeditor/tests/extending.rst | 2 +- plone/schemaeditor/tests/tests.py | 14 +++++++++++++- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/plone/schemaeditor/tests/choice.rst b/plone/schemaeditor/tests/choice.rst index d2d665e..d3c2a07 100644 --- a/plone/schemaeditor/tests/choice.rst +++ b/plone/schemaeditor/tests/choice.rst @@ -58,7 +58,7 @@ If duplicate values are entered an error is raised. ... ['Alaska', 'Russia', 'United States', 'United States', ... 'Other']) >>> browser.getControl('Save').click() - >>> print browser.contents + >>> print(browser.contents) <...
The 'United States' vocabulary value conflicts with 'United States'.
... @@ -118,7 +118,7 @@ We can't set a vocabulary name AND values. >>> browser.getLink(url='country').click() >>> browser.getControl('values').value = "oups" >>> browser.getControl('Save').click() - >>> print browser.contents + >>> print(browser.contents) <...
You can not set a vocabulary name AND vocabulary values.... ... @@ -166,7 +166,7 @@ If duplicate values are entered an error is raised. >>> ctl.value = '\n'.join( ... ['Lisp', 'Plone', 'Python', 'Lisp']) >>> browser.getControl('Save').click() - >>> print browser.contents + >>> print(browser.contents) <...
The 'Lisp' vocabulary value conflicts with 'Lisp'.
... @@ -210,7 +210,7 @@ Back to the edit form, vocabulary name is selected. >>> browser.open(portal_url + '/@@schemaeditor') >>> browser.getLink(url='categories').click() - >>> print browser.contents + >>> print(browser.contents) <... ... selected>plone.schemaeditor.test.Categories>> browser.open(portal_url + '/@@schemaeditor') Traceback (most recent call last): ... - Unauthorized: ...You are not authorized to access this resource... + zExceptions.unauthorized.Unauthorized: ...You are not authorized to access this resource... We need to log in as a manager, because by default only managers get the 'Manage Schemata' permission:: @@ -62,11 +62,11 @@ normalized form of the title):: >>> isinstance(IDummySchema['favorite_color'], TextLine) True >>> IDummySchema['favorite_color'].title - u'Favorite Color' + 'Favorite Color' >>> IDummySchema['favorite_color'].required True >>> IDummySchema['favorite_color'].description - u'Select your favorite color' + 'Select your favorite color' Editing a schema field attribute @@ -98,7 +98,7 @@ of schema fields, which should reflect the change:: Let's confirm that the new default value was correctly saved to the actual schema:: >>> IDummySchema['favorite_color'].description - u'Enter your favorite color.' + 'Enter your favorite color.' If the schema is edited to have internationalized attributes:: @@ -130,11 +130,11 @@ value was set:: >>> type(IDummySchema['favorite_color'].description) <... 'zope.i18nmessageid.message.Message'> >>> IDummySchema['favorite_color'].description - u'favorite_color' + 'favorite_color' >>> IDummySchema['favorite_color'].description.domain 'plone' >>> IDummySchema['favorite_color'].description.default - u'Enter your favorite color.' + 'Enter your favorite color.' Let's also check that the support for editing i18n Message values does not persist its marker interface:: @@ -193,7 +193,7 @@ testbrowser doesn't support Javascript):: [event: ContainerModifiedEvent on InterfaceClass] [event: SchemaModifiedEvent on DummySchemaContext] >>> browser.contents - '' + b'' Now the field should be the third field of the schema:: @@ -220,7 +220,7 @@ They are moved to the end of the new fieldset:: [event: ContainerModifiedEvent on InterfaceClass] [event: SchemaModifiedEvent on DummySchemaContext] >>> browser.contents - '' + b'' Now the field should be the seventh field of the schema:: @@ -236,7 +236,7 @@ They can be ordered into a fieldset:: [event: ContainerModifiedEvent on InterfaceClass] [event: SchemaModifiedEvent on DummySchemaContext] >>> browser.contents - '' + b'' >>> get_field_fieldset(IDummySchema, 'favorite_color')
@@ -301,7 +301,7 @@ move it into an other fieldset and remove it:: [event: ContainerModifiedEvent on InterfaceClass] [event: SchemaModifiedEvent on DummySchemaContext] >>> browser.contents - '' + b'' >>> browser.open('http://nohost/@@schemaeditor') >>> browser.getLink(url='other_set/@@delete').click() [event: ObjectRemovedEvent on TextLine] diff --git a/plone/schemaeditor/tests/extending.rst b/plone/schemaeditor/tests/extending.rst index a9f1825..8685e92 100644 --- a/plone/schemaeditor/tests/extending.rst +++ b/plone/schemaeditor/tests/extending.rst @@ -76,4 +76,4 @@ We can save a color and confirm that it ends up in the schema's tagged values:: [event: SchemaModifiedEvent on DummySchemaContext] >>> from plone.schemaeditor.tests.fixtures import IDummySchema >>> IDummySchema.getTaggedValue('color') - {'field1': u'green'} + {'field1': 'green'} diff --git a/plone/schemaeditor/tests/tests.py b/plone/schemaeditor/tests/tests.py index 3d4fc82..ba806a2 100644 --- a/plone/schemaeditor/tests/tests.py +++ b/plone/schemaeditor/tests/tests.py @@ -11,6 +11,8 @@ import doctest import os import plone.schemaeditor +import re +import six import unittest @@ -34,6 +36,15 @@ def tearDown(self): classImplements(implementedBy(BaseRequest) - ITestLayer) +class Py23DocChecker(doctest.OutputChecker): + def check_output(self, want, got, optionflags): + if six.PY2: + got = re.sub('zExceptions.unauthorized.Unauthorized', 'Unauthorized', got) + got = re.sub("u'(.*?)'", "'\\1'", want) + want = re.sub("b'(.*?)'", "'\\1'", want) + return doctest.OutputChecker.check_output(self, want, got, optionflags) + + def test_suite(): return unittest.TestSuite([ @@ -45,7 +56,8 @@ def test_suite(): 'minmax.rst', setUp=setUp, tearDown=tearDown, - optionflags=optionflags + optionflags=optionflags, + checker=Py23DocChecker(), ), ]) From 88158945d1b16eb03e0562a509db531d7b23c672 Mon Sep 17 00:00:00 2001 From: Philip Bauer Date: Fri, 15 Jun 2018 00:17:26 +0200 Subject: [PATCH 5/6] fix Py23DocChecker --- plone/schemaeditor/tests/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plone/schemaeditor/tests/tests.py b/plone/schemaeditor/tests/tests.py index ba806a2..e43aba1 100644 --- a/plone/schemaeditor/tests/tests.py +++ b/plone/schemaeditor/tests/tests.py @@ -39,8 +39,8 @@ def tearDown(self): class Py23DocChecker(doctest.OutputChecker): def check_output(self, want, got, optionflags): if six.PY2: - got = re.sub('zExceptions.unauthorized.Unauthorized', 'Unauthorized', got) - got = re.sub("u'(.*?)'", "'\\1'", want) + want = re.sub('zExceptions.unauthorized.Unauthorized', 'Unauthorized', want) + got = re.sub("u'(.*?)'", "'\\1'", got) want = re.sub("b'(.*?)'", "'\\1'", want) return doctest.OutputChecker.check_output(self, want, got, optionflags) From 9f03f1f88f04ff568aa276443c5b2c7b8361a0f2 Mon Sep 17 00:00:00 2001 From: Philip Bauer Date: Wed, 19 Sep 2018 09:15:45 +0200 Subject: [PATCH 6/6] add changenote and classifiers --- CHANGES.rst | 3 +++ setup.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index e690b5b..3b05f7e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -21,6 +21,9 @@ Bug fixes: - Allow defaults to be set on dexterity type fields via the web UI (@@fields) [ezvirtual] +- Fix tests in py3 and some py3 issues. + [pbauer] + 2.0.19 (2018-02-02) ------------------- diff --git a/setup.py b/setup.py index 067f12c..7cf34ec 100644 --- a/setup.py +++ b/setup.py @@ -16,8 +16,11 @@ "Framework :: Plone", "Framework :: Plone :: 5.0", "Framework :: Plone :: 5.1", + "Framework :: Plone :: 5.2", "Programming Language :: Python", "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules", "License :: OSI Approved :: BSD License", ],