Skip to content

Commit

Permalink
Take raiseHttpErrors into account on submit
Browse files Browse the repository at this point in the history
If an HTTPError is raised on `browser.submit`, it should only be
reraised to the user if `browser.raiseHttpErrors=True`.

This behavior already applies to `browser.open`, thus it is expected to
apply to `browser.submit` as well.
  • Loading branch information
nidico committed May 12, 2013
1 parent 53cdbbc commit 8596a29
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/zope/testbrowser/browser.py
Expand Up @@ -797,6 +797,10 @@ def submit(self, label=None, name=None, index=None, coord=(1,1)):
try:
try:
self.browser.mech_browser.open(request)
except mechanize.HTTPError, e:
if self.browser.raiseHttpErrors:
fix_exception_name(e)
raise
except Exception, e:
fix_exception_name(e)
raise
Expand Down

2 comments on commit 8596a29

@mgedmin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope there was a test for this in a separate commit, otherwise the fix is going to be lost when I merge the py3 branch.

@mgedmin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, found the test in commit b7a6959.

It's giving me a bit of trouble, since WebTest-based zope.testbrowser from the py3 branch doesn't have a .mech_browser attribute any more.

Please sign in to comment.