[Twisted-web] Possible bug in nevow.testutil.FakeRequest setHeaders and getHeaders

Peter Westlake peter.westlake at pobox.com
Tue Sep 28 13:23:51 EDT 2010

Recently my nevow web server's unit tests started to fail, because the
tests used request.getHeader() to check that request.setHeader() had
been called correctly. This used to work.

I can see from testutil.py that setHeaders sets self.headers, but
getHeaders gets a value from received_headers, and there is a test in
test_testutil.py to make sure it does. So is this really how it is meant
to work? Is setHeader really meant to set something that getHeader can't
get? If so, what's the correct method for testing the result of

To reproduce the problem, run this with "trial":

from nevow.testutil import FakeRequest, TestCase

class TestHeaders(TestCase):
    def setUp(self):
        self.request = FakeRequest()

    def test_set(self):
        self.request.setHeader('location', 'somewhere')


More information about the Twisted-web mailing list