I have a test in Django 1.5 that passes in these conditions:
- when run by itself in isolation
- when the full
TestCase
is run - when all of my app's tests are run
But it fails when the full test suite is run with python manage.py test
. Why might this be happening?
The aberrant test uses django.test.Client
to POST
some data to an endpoint, and then the test checks that an object was successfully updated. Could some other app be modifying the test client or the data itself?
I have tried some print debugging and I see all of the data being sent and received as expected. The specific failure is a does-not-exist exception that is raised when I try to fetch the to-be-updated object from the db. Strangely, in the exception handler itself, I can query for all objects of that type and see that the target object does in fact exist.
Edit:
My issue was resolved when I found that I was querying for the target object by id
and User
and not id
and UserProfile
, but it's still confusing to me that this would work in some cases but fail in others.
I also found that the test would fail with python manage.py test auth <myapp>