Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests for py3 #8

Merged
merged 2 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ New features:

Bug fixes:

- *add item here*
- Fix tests for py3
[pbauer]


2.2.1 (2018-02-02)
Expand Down
18 changes: 9 additions & 9 deletions plone/browserlayer/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
--------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
11 changes: 11 additions & 0 deletions plone/browserlayer/tests/test_doctest.py
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -15,6 +25,7 @@ def test_suite():
doctest.ELLIPSIS |
doctest.REPORT_ONLY_FIRST_FAILURE
),
checker=Py23DocChecker(),
),
layer=PLONEBROWSERLAYER_FUNCTIONAL_TESTING
)
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down