Accessing browser.headers before the first request generates an error.

Bug #605907 reported by Benji York
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zope.testbrowser
Invalid
Undecided
Unassigned

Bug Description

>>> import zope.testbrowser.browser
>>> b = zope.testbrowser.browser.Browser()
>>> b.headers
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/benji/launchpad/lp-sourcedeps/eggs/zope.testbrowser-3.7.0a1-py2.6.egg/zope/testbrowser/browser.py", line 210, in headers
    return self.mech_browser.response().info()
AttributeError: 'NoneType' object has no attribute 'info'
>>> b.open('http://example.com')
>>> b.headers
<httplib.HTTPMessage instance at 0xa6ea90c>

Revision history for this message
Marius Gedminas (mgedmin) wrote :

For comparison purposes:

  - Accessing b.contents raises AttributeError: 'NoneType' object has no attribute 'tell'
  - Accessing b.url, b.title, b.isHtml, or calling b.getForm(), b.getControl(), b.getLink() all raise mechanize._mechanize.BrowserStateError: not viewing any document

I don't really care about this, but I suppose it would make sense to have both b.contents and b.headers also raise BrowserStateError before you make the first request.

Revision history for this message
Colin Watson (cjwatson) wrote :

The zope.testbrowser project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope.testbrowser.

Changed in zope.testbrowser:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.