On Tuesday 21 February 2017 19:00:42 'Tom Evans' via Django users wrote:

> Previously, these instances were loaded from a JSON fixtures file,

And you can still do that.

> which used to be the recommended way. For our own tests, we simply
> load these fixtures in the setUp portion of the test; obviously we
> can't go around modifying tests in third party libraries.
> I tried taking them out of the fixtures, and adding them instead in a
> data migration, but this also had the same effect - the instances were
> there for the first test ran, and then missing for all the subsequent
> ones.

setUp is run between test methods of a test case. setupTestData is a class 
method on 
the testcase run once per test case.
> 
> 
> What is the "correct" way of ensuring that these instances exist in
> the test database before any test is run?

All explained in the docs[1].
Either redeclare the same fixtures for different test cases or reorganize your 
testcases to share the same fixture(s).
-- 
Melvyn Sopacua

--------
[1] 
https://docs.djangoproject.com/en/1.10/topics/testing/tools/#django.test.TransactionTe
stCase.fixtures

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3888092.mWS3N5nSI1%40devstation.
For more options, visit https://groups.google.com/d/optout.

Reply via email to