When using Mechanize, exception in the application code used to bubbleup into the test by default.
But when using requests, this is not possible, resulting in HTTP errors. This behavior is inconsistent between drivers and it is not the same as what happens with real browsers. It is important though that the developer is notified of unexpected HTTP errors.
In order to clean up the inconsistencies and provide better tooling for working with exceptions various changes are made:
Exceptions are no longer bubbling up by default in mechanize. The option browser.exception_bubbling = True enables the old behavior.
The x-zope-handle-errors is now forbidden so that the testbrowser is in complete control of this behavior; use exception_bubbling instead.
New exceptions HTTPClientError and HTTPServerError are added and are raised by all drivers by default.
The option browser.raise_http_errors = False allows to disable the HTTP exceptions.
With the new browser.expect_http_error context manager a simple tool for asserting HTTP errors is provided.
A new property browser.status_code provides the last responses status code.
A new property browser.status_reason provides the last responses reason.
When using Mechanize, exception in the application code used to bubbleup into the test by default. But when using requests, this is not possible, resulting in HTTP errors. This behavior is inconsistent between drivers and it is not the same as what happens with real browsers. It is important though that the developer is notified of unexpected HTTP errors.
In order to clean up the inconsistencies and provide better tooling for working with exceptions various changes are made:
browser.exception_bubbling = True
enables the old behavior.x-zope-handle-errors
is now forbidden so that the testbrowser is in complete control of this behavior; useexception_bubbling
instead.HTTPClientError
andHTTPServerError
are added and are raised by all drivers by default.browser.raise_http_errors = False
allows to disable the HTTP exceptions.browser.expect_http_error
context manager a simple tool for asserting HTTP errors is provided.browser.status_code
provides the last responses status code.browser.status_reason
provides the last responses reason.Fixes #46