Skip to content

Commit

Permalink
Fixed LP #419119: return None when the browser has no contents instea…
Browse files Browse the repository at this point in the history
…d of

raising an exception.

Backport r103586
  • Loading branch information
menesis committed Mar 5, 2012
1 parent acf600f commit 86bb08b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Expand Up @@ -7,6 +7,9 @@ CHANGES

- Fixed Python2.7 compatibility in Browser.handleErrors.

- Fixed LP #419119: return None when the browser has no contents instead of
raising an exception.

- Fix tests on Python 2.7

3.6.0a2 (2009-01-31)
Expand Down
2 changes: 2 additions & 0 deletions src/zope/testbrowser/browser.py
Expand Up @@ -198,6 +198,8 @@ def contents(self):
if self._contents is not None:
return self._contents
response = self.mech_browser.response()
if response is None:
return None
old_location = response.tell()
response.seek(0)
self._contents = response.read()
Expand Down
13 changes: 13 additions & 0 deletions src/zope/testbrowser/tests.py
Expand Up @@ -304,6 +304,19 @@ def test_file_upload():
"""

def test_new_instance_no_contents_should_not_fail(self):
"""
When first instantiated, the browser has no contents.
(Regression test for <http://bugs.launchpad.net/zope3/+bug/419119>)
>>> browser = Browser()
>>> print browser.contents
None
"""



def test_strip_linebreaks_from_textarea(self):
"""
Expand Down

0 comments on commit 86bb08b

Please sign in to comment.