I ended up doing the test something like this:
>>> browser.mech_browser.set_handle_redirect(False) >>> from urllib2 import HTTPError >>> try: ... browser.open('url-that-should-redirect') ... except HTTPError, exc: ... print str(exc) ... print exc.headers.getheader('Location') HTTP Error 303: See Other redirect-destination-url
Accessing the network from the tests was never my intention: rather just to check that the destination of the redirect was correct.
Maybe some API to do the equivalent of the set_handle_redirect(False) call would be appropriate?
I ended up doing the test something like this:
>>> browser. mech_browser. set_handle_ redirect( False) open('url- that-should- redirect' ) getheader( 'Location' ) destination- url
>>> from urllib2 import HTTPError
>>> try:
... browser.
... except HTTPError, exc:
... print str(exc)
... print exc.headers.
HTTP Error 303: See Other
redirect-
Accessing the network from the tests was never my intention: rather just to check that the destination of the redirect was correct.
Maybe some API to do the equivalent of the set_handle_ redirect( False) call would be appropriate?