Ah, turns out all you have to do is specify -

    fixtures = [ 'initial_data' ]

... in the TestCase and it'll load all the initial_data fixtures from
all apps. Still a bit odd that loading initial_data fixtures isn't the
default in tests though.

On 3 October 2013 16:49, Sam Lai <samuel....@gmail.com> wrote:
> I'm trying to test a Django management command in app X that parses
> data files and inserts data into models that are located in apps Y and
> Z. Apps Y and Z have initial_data.json files in them. On running my
> test however, it seems that my initial_data fixtures are not being
> loaded.
>
> I could specify the initial_data fixtures manually (presumably I can
> do ../) using the 'fixtures' variable in my TestCase, but that isn't
> very DRY and becomes tedious when more apps are introduced with their
> own initial_data.
>
> I tracked this down to a change that Russell made 3 years ago
> (https://github.com/django/django/commit/b31a1b99261d05bf8a34495ee9faf4d6592b8b36).
> The commit message and content explains why *custom SQL* fixtures
> aren't loaded automatically during testing, but says nothing about why
> xml/yaml/json fixtures are no longer loaded either.
>
> All django-users threads that I can find on this refer to the
> situation prior to this change, and state that initial_data fixtures
> *were* loaded.
>
> What's the reason for the change? I thought initial_data is designed
> for data that should always be in the database, so this is a bit odd.
> Can't really find anything in the docs that mentions this either.
>
> Thanks,
>
> Sam

-- 
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/CABxbXqVVkeMaXvnYco%2Bd8kbRFz9LJfpaR8c9kx085kHTtP4a9g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to