Skip to content

Commit

Permalink
Fixed test for 'Connection refused' which could be 'Connection reset'.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritsvanrees committed Mar 1, 2019
1 parent 4219a3c commit e7a34f5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions news/59.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed test for 'Connection refused' which could be 'Connection reset'. [maurits]
15 changes: 11 additions & 4 deletions src/plone/testing/zope.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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: <urlopen error [Errno ...] Connection refused>
We can expect one of these exceptions:
- URLError: <urlopen error [Errno ...] Connection refused>
- 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')
16 changes: 12 additions & 4 deletions src/plone/testing/zserver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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: <urlopen error [Errno ...] Connection refused>
We can expect one of these exceptions:
- URLError: <urlopen error [Errno ...] Connection refused>
- 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
~~~~~~~~~~
Expand Down

0 comments on commit e7a34f5

Please sign in to comment.