zopefoundation / zope.testbrowser

Programmable browser for functional black-box tests
Other
21 stars 16 forks source link

Take raiseHttpErrors into account on submit #4

Closed nidico closed 11 years ago

nidico commented 11 years ago

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.

kedder commented 11 years ago

Thanks nidico. Could you please add a test which recreates this behavior?

nidico commented 11 years ago

@kedder: Sure - I'm just not getting the test suite to run - bin/test yields:

ImportError: cannot import name pystone

I've built zope.testbrowser in a virtualenv using the enclosed buildout configuration. Any idea?

mgedmin commented 11 years ago

If you can't get buildout to work, you may try tox (or detox) instead for running tests.

I've never seen the 'cannot import name pystone' error. It looks like somehow the Python stdib's test package gets mixed in where it shouldn't. If you could pastebin the full traceback somewhere, maybe that could shine some light on the issue.

nidico commented 11 years ago

I've moved my build / test problems to a separate issue - #5.

nidico commented 11 years ago

I've now added some tests which confirm the expected behavior.

nidico commented 11 years ago

@kedder / @mgedmin: Could you please have another look at this and merge if appropriate? Thanks!

mgedmin commented 11 years ago

Have you signed the Zope Committer Agreement? I don't think I'm allowed to merge code from people who haven't signed it.

(Unless it's a trivial change, but I don't know if this counts. /cc: @jimfulton)

nidico commented 11 years ago

@mgedmin:

Have you signed the Zope Committer Agreement?

Not yet, but I'll do as soon as http://foundation.zope.org/agreements is accessible again.

nidico commented 11 years ago

@mgedmin: My committer agreement has been signed and approved. Thanks for your support!

mgedmin commented 11 years ago

Thanks!

mgedmin commented 11 years ago

@nidico, I suspect the upcoming zope.testbrowser release is going to cause you pain: it switches the backend from mechanize (which doesn't support Python 3 and is barely maintained) to WebTest (which does and is). This means the '.mech_browser' attribute is going away.

I suspect you want a new API in zope.testbrowser itself, Browser.handleRedirects = False. Is that so?

It should be a simple change in Browser._processRequest(). The existing test_no_redirect will serve perfectly well as a unit test for this new API. I can make the change myself, but it would be better if you could test it with your existing test suite -- perhaps you'll discover other incompatibilities in the upcoming zope.testbrowser 4.1.0.