For one of my functional tests, I decided to use unittest.TestCase instead of a Django test class because it was convenient when cleaning up the test to have direct access to my local development database in the test itself.
Running the test in isolation like so passes as I'd expect: $ python manage.py test functional_tests.test_functionality System check identified no issues (0 silenced). ... ---------------------------------------------------------------------- Ran 3 tests in 0.040s OK When I try to run all tests at the same time, however, that test specifically errors out, complaining that an object DoesNotExist, as though it were using the Django test database: $ python manage.py test functional_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..................E.. ====================================================================== ERROR: some_functional_test (functional_tests.test_functionality.FunctionalTest) ---------------------------------------------------------------------- Traceback (most recent call last): ... etc. app.models.Object.DoesNotExist: Object matching query does not exist. ---------------------------------------------------------------------- Ran 21 tests in 0.226s FAILED (errors=1) Destroying test database for alias 'default'... I assume the error is with my trying use Object.objects.latest('created') when no Objects exist in Django's test database. Is there some way to prevent Django from wrapping all tests in whatever it is about the test runner that prevents my test from accessing an Object directly? I'm currently working around the issue by quarantining unittest.TestCase tests in their own directory so that I can run them as a suite, but it'll still error out if I ever want to run everything with manage.py test. If some additional context is helpful, I'm running functional tests against an API endpoint running on my local server. I'm testing a create method, and I'm trying to avoid having to request DELETE against the endpoint (I haven't even implemented DELETE yet) to clean up the test record created by the test. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4afd3494-431b-4f18-b5a3-461635989e4an%40googlegroups.com.