diff --git a/CHANGES.rst b/CHANGES.rst index a991459..c919d81 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,7 +14,8 @@ New features: Bug fixes: -- *add item here* +- Fix tests for py3 + [pbauer] 2.2.1 (2018-02-02) diff --git a/plone/browserlayer/README.rst b/plone/browserlayer/README.rst index df3031b..5962037 100644 --- a/plone/browserlayer/README.rst +++ b/plone/browserlayer/README.rst @@ -18,12 +18,12 @@ Before the product is installed, we cannot view this: >>> browser.open(layer['portal'].absolute_url() + '/@@layer-test-view') Traceback (most recent call last): ... - HTTPError: HTTP Error 404: Not Found + urllib.error.HTTPError: HTTP Error 404: Not Found We can view a view registered for the default layer, though: >>> browser.open(layer['portal'].absolute_url() + '/@@standard-test-view') - >>> print browser.contents + >>> print(browser.contents) A standard view However, if we install the product the interface is registered in the local @@ -40,14 +40,14 @@ And if we now traverse over the site root and render the view, it should be there. >>> browser.open(layer['portal'].absolute_url() + '/@@layer-test-view') - >>> print browser.contents + >>> print(browser.contents) A local view Unlike when applying a new skin, layers installed in this way do not override views registered for the default layer. >>> browser.open(layer['portal'].absolute_url() + '/@@standard-test-view') - >>> print browser.contents + >>> print(browser.contents) A standard view It is also possible to uninstall a layer: @@ -61,7 +61,7 @@ It is also possible to uninstall a layer: >>> browser.open(layer['portal'].absolute_url() + '/@@layer-test-view') Traceback (most recent call last): ... - HTTPError: HTTP Error 404: Not Found + urllib.error.HTTPError: HTTP Error 404: Not Found GenericSetup support -------------------- @@ -102,11 +102,11 @@ the next three lines are used because of this bug :https://dev.plone.org/ticket/ And just to prove that everything still works: >>> browser.open(layer['portal'].absolute_url() + '/@@layer-test-view') - >>> print browser.contents + >>> print(browser.contents) A local view >>> browser.open(layer['portal'].absolute_url() + '/@@standard-test-view') - >>> print browser.contents + >>> print(browser.contents) A standard view We now also have uninstall support. For the purposes of @@ -148,8 +148,8 @@ as expected: >>> browser.open(layer['portal'].absolute_url() + '/@@layer-test-view') Traceback (most recent call last): ... - HTTPError: HTTP Error 404: Not Found + urllib.error.HTTPError: HTTP Error 404: Not Found >>> browser.open(layer['portal'].absolute_url() + '/@@standard-test-view') - >>> print browser.contents + >>> print(browser.contents) A standard view diff --git a/plone/browserlayer/tests/test_doctest.py b/plone/browserlayer/tests/test_doctest.py index 52a0540..ae839ea 100644 --- a/plone/browserlayer/tests/test_doctest.py +++ b/plone/browserlayer/tests/test_doctest.py @@ -1,10 +1,20 @@ # -*- coding: utf-8 -*- from plone.browserlayer.testing import PLONEBROWSERLAYER_FUNCTIONAL_TESTING from plone.testing import layered + import doctest +import re +import six import unittest +class Py23DocChecker(doctest.OutputChecker): + def check_output(self, want, got, optionflags): + if six.PY2: + want = re.sub('urllib.error.HTTPError', 'HTTPError', want) + return doctest.OutputChecker.check_output(self, want, got, optionflags) + + def test_suite(): return unittest.TestSuite([ layered( @@ -15,6 +25,7 @@ def test_suite(): doctest.ELLIPSIS | doctest.REPORT_ONLY_FIRST_FAILURE ), + checker=Py23DocChecker(), ), layer=PLONEBROWSERLAYER_FUNCTIONAL_TESTING ) diff --git a/setup.py b/setup.py index 104bcac..67984fa 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,8 @@ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", ], keywords='plone browser layer', author='Plone Foundation',