From e7a34f57749bed8612e084c0c22e13a190d6ef72 Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Fri, 1 Mar 2019 17:32:06 +0100 Subject: [PATCH 1/3] Fixed test for 'Connection refused' which could be 'Connection reset'. --- news/59.bugfix | 1 + src/plone/testing/zope.rst | 15 +++++++++++---- src/plone/testing/zserver.rst | 16 ++++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 news/59.bugfix diff --git a/news/59.bugfix b/news/59.bugfix new file mode 100644 index 0000000..59f688a --- /dev/null +++ b/news/59.bugfix @@ -0,0 +1 @@ +Fixed test for 'Connection refused' which could be 'Connection reset'. [maurits] diff --git a/src/plone/testing/zope.rst b/src/plone/testing/zope.rst index 61cdb79..9c351de 100644 --- a/src/plone/testing/zope.rst +++ b/src/plone/testing/zope.rst @@ -523,7 +523,14 @@ When the server is torn down, the WSGIServer thread is stopped.:: Tear down plone.testing.zope.Startup in ... seconds. Tear down plone.testing.zca.LayerCleanup in ... seconds. - >>> conn = urlopen(app_url + '/folder1', timeout=5) - Traceback (most recent call last): - ... - URLError: +We can expect one of these exceptions: +- URLError: +- error: [Errno 104] Connection reset by peer + + >>> try: + ... conn = urlopen(app_url + '/folder1', timeout=5) + ... except Exception as exc: + ... if 'Connection refused' not in str(exc) and 'Connection reset' not in str(exc): + ... raise exc + ... else: + ... print('urlopen should have raised exception') diff --git a/src/plone/testing/zserver.rst b/src/plone/testing/zserver.rst index df94d1c..d7ec4f4 100644 --- a/src/plone/testing/zserver.rst +++ b/src/plone/testing/zserver.rst @@ -526,10 +526,18 @@ When the server is torn down, the ZServer thread is stopped.:: Tear down plone.testing.zserver.Startup in ... seconds. Tear down plone.testing.zca.LayerCleanup in ... seconds. - >>> conn = urllib2.urlopen(app_url + '/folder1', timeout=5) - Traceback (most recent call last): - ... - URLError: +We can expect one of these exceptions: +- URLError: +- error: [Errno 104] Connection reset by peer + + >>> try: + ... conn = urllib2.urlopen(app_url + '/folder1', timeout=5) + ... except Exception as exc: + ... if 'Connection refused' not in str(exc) and 'Connection reset' not in str(exc): + ... raise exc + ... else: + ... print('urllib2.urlopen should have raised exception') + FTP server ~~~~~~~~~~ From cc3fe1a7598107b9edee75412a1bd9c04a07269a Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Fri, 1 Mar 2019 20:53:36 +0100 Subject: [PATCH 2/3] Fixed flake8 errors, and ignore W503. Either W503 will fail or W504. lint-py27 runtests: commands[2] | flake8 --doctests src tests setup.py src/plone/testing/layer.py:126:26: W504 line break after binary operator src/plone/testing/layer.py:127:74: W504 line break after binary operator setup.py:49:36: W504 line break after binary operator --- setup.py | 5 +++-- src/plone/testing/layer.py | 6 +++--- tox.ini | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 9fd0f00..cde47b9 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ import os import os.path + version = '7.0.1.dev0' install_requires = [ @@ -46,8 +47,8 @@ long_description=(u'\n\n'.join([ open(os.path.join("src", "plone", "testing", "README.rst")).read(), open("CHANGES.rst").read(), - "Detailed documentation\n" + - "======================", + "Detailed documentation\n" + + "======================", open(os.path.join("src", "plone", "testing", "layer.rst")).read(), open(os.path.join("src", "plone", "testing", "zca.rst")).read(), open(os.path.join("src", "plone", "testing", "security.rst")).read(), diff --git a/src/plone/testing/layer.py b/src/plone/testing/layer.py index a95b8c6..90dc791 100644 --- a/src/plone/testing/layer.py +++ b/src/plone/testing/layer.py @@ -123,9 +123,9 @@ def _mergeResourceManagers(self, seqs): def _resourceResolutionOrder(self, instance): return self._mergeResourceManagers( - [[instance]] + - list(map(self._resourceResolutionOrder, instance.__bases__)) + - [list(instance.__bases__)] + [[instance]] + + list(map(self._resourceResolutionOrder, instance.__bases__)) + + [list(instance.__bases__)] ) diff --git a/tox.ini b/tox.ini index 4cf753d..4efe363 100644 --- a/tox.ini +++ b/tox.ini @@ -81,7 +81,7 @@ deps = commands = mkdir -p {toxinidir}/_build/reports/flake8 - flake8 --format=html --htmldir={toxinidir}/_build/reports/flake8 --doctests src setup.py - flake8 --doctests src tests setup.py + flake8 --doctests --ignore=W503 src tests setup.py isort --check-only --recursive {toxinidir}/src whitelist_externals = From 6f92e577c80efa052661c11cf9a724def38837cc Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Fri, 1 Mar 2019 20:57:53 +0100 Subject: [PATCH 3/3] Disable flake8-pytest and flake8-todo. It's strange. Without this, when I run flake8 I get this: $ .tox/lint-py27/bin/flake8 --doctests src tests setup.py src/plone/testing/layer.py:127:13: W503 line break before binary operator src/plone/testing/layer.py:128:13: W503 line break before binary operator setup.py:51:9: W503 line break before binary operator We should ignore W503, so I pass an extra option, and then I get different errors: $ .tox/lint-py27/bin/flake8 --doctests --ignore=W503 src tests setup.py src/plone/testing/zope.py:124:19: T000 Todo note found. src/plone/testing/tests.py:95:9: T003 use of Django-style assert statement found (instead of regular assert): assertIsNotNone --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 4efe363..7447371 100644 --- a/tox.ini +++ b/tox.ini @@ -62,8 +62,8 @@ deps = flake8-debugger flake8-deprecated flake8-print - flake8-pytest - flake8-todo + # flake8-pytest + # flake8-todo flake8-isort mccabe # Potential flake8 plugins that should be used: # TBD