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

Bug #605907 reported by Benji York on 2010-07-15
This bug affects 1 person
Affects Status Importance Assigned to Milestone

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/", line 210, in headers
    return self.mech_browser.response().info()
AttributeError: 'NoneType' object has no attribute 'info'
>>> b.headers
<httplib.HTTPMessage instance at 0xa6ea90c>

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.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers