Hi, I am facing a similar issue and have not found any solution yet. I was wondering if you had been able to fix this?
On Tuesday, 31 March 2015 22:27:32 UTC+2, Peter Bengtsson wrote: > > I have this code that looks something like this (django 1.6.11): > > def test_something(self): > url = someobject.get_url() > User.objects.create_user('a', 'a...@example.com <javascript:>', > 'secret') > assert self.client.login(username='a', password='secret') > r = self.client.get(url) > assert r.status_code == 302 # because you're not allowed to view it > someobject.privacy_setting = 'different' > r = self.client.get(url) > assert r.status_code == 200 # now you can view it according the > business logic > > > This code has been working for many many months but suddenly it started to > Heisenfail with the last line being 302 != 200. > It might be related to caching somewhere else because it ONLY ever fails > (if it fails!) when I run the whole test suite. > After a lot of painful debugging I concluded that sometimes, that last > self.client.get(url) causes `request.user == <SimpleLazyObject: > <django.contrib.auth.models.AnonymousUser object at 0x112318f50>>` > > I.e. for the second request made by that logged in client, it's all of a > sudden NOT logged in!! Not always. Only sometimes. :( > > I put in a debugging line just before that last test like `assert > self.client.session['_auth_user_id']` and that sometimes fails. Almost as > if the testclient loses its session store DURING the lifetime of the test. > Sometimes. > > > Anybody seen anything similar that might be able to explain it or give me > a clue? > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/aaca3ca4-098a-4e66-8c63-e3d54baa4036%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.