On Tuesday 02 September 2014 15:27:53 Josh Smeaton wrote:
>
> As far as I'm concerned, using fixtures is the wrong way to populate data
> for tests. You're much better off creating the objects you need for each
> test within the test, or creating them directly inside the setUp method.
+1.
> You avoid the parsing and loading of json data, which is quite substantial!
This I find a rather weak argument. The main reason to create test-objects in
code rather than fixtures is that models evolve (especially when thinking about
Django>=1.7), and fixtures are pretty close to impossible to adapt. I've been
involved in efforts to do the automatic adaptations (essentially, start with an
empty DB and code at the commit before the change; load the fixture, update
sources, migrate, and dump the new fixture). There are significant problems with
this approach (e.g. if the code that does this sits in the same repo as the
project code, then fixes to some parts of it need to be added with a time
machine).
HTH,
Shai.