Skip to content

Commit

Permalink
fix tests for py3
Browse files Browse the repository at this point in the history
  • Loading branch information
pbauer committed Jun 24, 2018
1 parent e9aa9d0 commit 6a40c04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
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

1 comment on commit 6a40c04

@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.browserlayer/15/violations

plone/browserlayer/exportimport.py:96:21: Q000 Remove bad quotes.
plone/browserlayer/exportimport.py:102:20: S001 found module formatter
plone/browserlayer/exportimport.py:115:21: Q000 Remove bad quotes.
plone/browserlayer/exportimport.py:121:20: S001 found module formatter
plone/browserlayer/testing.py:20:10: Q000 Remove bad quotes.
plone/browserlayer/testing.py:20:40: C812 missing trailing comma
plone/browserlayer/__init__.py:0:1: C101 Coding magic comment not found
plone/browserlayer/utils.py:37:24: Q000 Remove bad quotes.
plone/browserlayer/utils.py:37:24: S001 found module formatter
plone/browserlayer/layer.py:12:31: Q000 Remove bad quotes.
plone/browserlayer/layer.py:29:5: D001 found directlyProvides( replace it with zope.interface.provider
plone/browserlayer/tests/test_doctest.py:30:55: C812 missing trailing comma
plone/browserlayer/tests/test_doctest.py:31:10: C812 missing trailing comma

Follow these instructions to reproduce it locally.

Please sign in to comment.