> I'm following the instructions
> at http://code.gustavonarea.net/repoze.who-testutil/HowTo/TestingProtected
> Areas.html for forging authentication for the purpose of functional
> testing. I've written three tests so far. When I run my test suite, one
> test fails on account of a 403 error, and the other two pass. However, if
> I comment out the two passing tests, running only the test that previously
> failed, it passes.
Are you reusing the webtest.TestApp object across tests? I mean something like
def __init__(self, *args, **kwargs):
TestCase.__init__(self, *args, **kwargs)
self.app = webtest.TestApp(... whatever ...)
test_one() and test_two() wouldn't be isolated. The first test to be run could
affect the result of the second one if cookies are used.
> Is there some kind of setup or teardown necessary in order to ensure the
> forged auth works every time?
Making sure that each test uses a fresh test application should be enough. A
setUp() like this following is all you should need:
wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
self.app = TestApp(wsgiapp)
Although if you're using Pylons it'd need a few more lines:
Please let me know if that solves the problem. If not, please post the test
case with the three tests, and the setUp() and __init__() methods.
Gustavo Narea <xri://=Gustavo>.
| Tech blog: =Gustavo/(+blog)/tech ~ About me: =Gustavo/about |
Repoze-dev mailing list