Apparently, this is a cookie related issue: http://stackoverflow.com/questions/2705235/django-test-failing-on-a-view-with-login-required
I'm using Django 1.1.1 for use with Django-CMS and Python 2.6.5, so the problem with cookies as described by the Stack Overflow article explains why my test fails :( Hope this helps someone, Brandon On Oct 5, 11:37 pm, Brandon Taylor <btaylordes...@gmail.com> wrote: > Hi everyone, > > I set up a bare-bones project with one view decorated with > @login_required. > I created an initial_data.json fixture with a user. > I called self.client.login(username='foobar', passowrd='foobar') and > it returned True. > I assigned a response variable from self.client.get('/protected/') > > and self.assertEqual(response.status_code, 200) fails. > > Instead, it's returning a 302 to 'http://testserver/accounts/login/? > next=/protected > Why is that? > > Here is my test case: > > class SimpleTest(TestCase): > def test_protected(self): > logged_in = self.client.login(username='foobar', > passowrd='foobar') > self.failUnless(logged_in) > > response = self.client.get('/protected/') > self.assertEqual(response.status_code, 200) > > Which results in: > AssertionError: 302 != 200 > > What am I doing wrong? Any help GREATLY appreciated! > Brandon -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.