Skip to content

Commit

Permalink
Merge pull request #60 from plone/python3
Browse files Browse the repository at this point in the history
Python3
  • Loading branch information
pbauer authored Sep 19, 2018
2 parents f50e596 + 9f03f1f commit 7100cee
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion plone/schemaeditor/browser/schema/add_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion plone/schemaeditor/browser/schema/traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from zope.publisher.interfaces.browser import IBrowserPublisher
from ZPublisher.BaseRequest import DefaultPublishTraverse

import six


@implementer(ISchemaContext, IBrowserPublisher)
class SchemaContext(SimpleItem):
Expand All @@ -21,7 +23,6 @@ class SchemaContext(SimpleItem):
enableFieldsets = True

def __init__(self, context, request, name=u'schema', title=None):
super(SchemaContext, self).__init__(context, request)
self.schema = context
self.request = request

Expand Down
8 changes: 4 additions & 4 deletions plone/schemaeditor/tests/choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<...
<div class="error">The 'United States' vocabulary value conflicts with 'United States'.</div>
...
Expand Down Expand Up @@ -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)
<...
<div class="error">You can not set a vocabulary name AND vocabulary values....
...
Expand Down Expand Up @@ -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)
<...
<div class="error">The 'Lisp' vocabulary value conflicts with 'Lisp'.</div>
...
Expand Down Expand Up @@ -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</option...
...
20 changes: 10 additions & 10 deletions plone/schemaeditor/tests/editing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ error::
>>> 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::

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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::

Expand Down Expand Up @@ -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::
Expand Down Expand Up @@ -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::

Expand All @@ -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::

Expand All @@ -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')
<Fieldset 'alpha'...of favorite_color, fieldA>

Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion plone/schemaeditor/tests/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
14 changes: 13 additions & 1 deletion plone/schemaeditor/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import doctest
import os
import plone.schemaeditor
import re
import six
import unittest


Expand All @@ -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:
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)


def test_suite():
return unittest.TestSuite([

Expand All @@ -45,7 +56,8 @@ def test_suite():
'minmax.rst',
setUp=setUp,
tearDown=tearDown,
optionflags=optionflags
optionflags=optionflags,
checker=Py23DocChecker(),
),

])
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down

1 comment on commit 7100cee

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pbauer Jenkins CI reporting about code analysis
See the full report here: https://jenkins.plone.org/job/package-plone.schemaeditor/47/violations

plone/schemaeditor/testing.py:26:22: C812 missing trailing comma
plone/schemaeditor/interfaces.py:33:26: C812 missing trailing comma
plone/schemaeditor/interfaces.py:48:76: C812 missing trailing comma
plone/schemaeditor/interfaces.py:52:38: C812 missing trailing comma
plone/schemaeditor/interfaces.py:59:30: C812 missing trailing comma
plone/schemaeditor/interfaces.py:68:22: C812 missing trailing comma
plone/schemaeditor/interfaces.py:150:33: C812 missing trailing comma
plone/schemaeditor/interfaces.py:162:22: C812 missing trailing comma
plone/schemaeditor/interfaces.py:175:23: C812 missing trailing comma
plone/schemaeditor/interfaces.py:190:69: C812 missing trailing comma
plone/schemaeditor/interfaces.py:202:80: C812 missing trailing comma
plone/schemaeditor/interfaces.py:207:72: C812 missing trailing comma
plone/schemaeditor/interfaces.py:215:22: C812 missing trailing comma
plone/schemaeditor/interfaces.py:227:23: C812 missing trailing comma
plone/schemaeditor/utils.py:84:9: T000 Todo note found.
plone/schemaeditor/utils.py:100:18: C812 missing trailing comma
plone/schemaeditor/utils.py:104:12: P002 found "hasattr", consider replacing it
plone/schemaeditor/utils.py:115:16: P002 found "hasattr", consider replacing it
plone/schemaeditor/utils.py:125:18: C812 missing trailing comma
plone/schemaeditor/utils.py:149:26: C812 missing trailing comma
plone/schemaeditor/fields.py:71:58: C812 missing trailing comma
plone/schemaeditor/fields.py:72:14: C812 missing trailing comma
plone/schemaeditor/fields.py:130:9: E303 too many blank lines (2)
plone/schemaeditor/fields.py:227:35: C812 missing trailing comma
plone/schemaeditor/fields.py:228:20: C812 missing trailing comma
plone/schemaeditor/browser/field/fieldset.py:4:1: I001 isort found an import in the wrong position
plone/schemaeditor/browser/field/edit.py:28:1: I004 isort found an unexpected blank line in imports
plone/schemaeditor/browser/field/edit.py:179:12: P002 found "hasattr", consider replacing it
plone/schemaeditor/browser/field/edit.py:187:42: C812 missing trailing comma
plone/schemaeditor/browser/schema/add_field.py:79:76: C812 missing trailing comma
plone/schemaeditor/browser/schema/add_field.py:80:18: C812 missing trailing comma
plone/schemaeditor/browser/schema/add_field.py:112:41: C812 missing trailing comma
plone/schemaeditor/browser/schema/listing.py:55:16: P002 found "hasattr", consider replacing it
plone/schemaeditor/browser/schema/listing.py:109:79: C812 missing trailing comma
plone/schemaeditor/browser/schema/add_fieldset.py:34:79: C812 missing trailing comma
plone/schemaeditor/browser/schema/add_fieldset.py:38:33: C812 missing trailing comma
plone/schemaeditor/browser/schema/add_fieldset.py:54:41: C812 missing trailing comma
plone/schemaeditor/browser/schema/traversal.py:9:1: F401 'six' imported but unused
plone/schemaeditor/browser/schema/traversal.py:45:21: C812 missing trailing comma
plone/schemaeditor/tests/tests.py:8:1: I001 isort found an import in the wrong position
plone/schemaeditor/tests/tests.py:42:80: E501 line too long (88 > 79 characters)
plone/schemaeditor/tests/test_fields.py:27:19: C812 missing trailing comma
plone/schemaeditor/tests/test_fields.py:35:45: C812 missing trailing comma
plone/schemaeditor/tests/test_fields.py:40:48: C812 missing trailing comma
plone/schemaeditor/tests/test_fields.py:48:44: C812 missing trailing comma
plone/schemaeditor/tests/test_fields.py:53:47: C812 missing trailing comma
plone/schemaeditor/tests/test_robot.py:26:33: C812 missing trailing comma

Follow these instructions to reproduce it locally.

Please sign in to comment.