Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#24023 closed Bug (duplicate)

Apps with intial_data and migrations kill test runner

Reported by: Alex Hayes Owned by: nobody
Component: Testing framework Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It appears that in Django 1.7.1 when you run manage.py test it attempts to loaddata for apps with initial_data.* prior(1) to the migrations for those apps being applied.

According to the docs the loading of initial_data.* files has been deprecated in 1.7.

I would expect and assume that this is true for running tests also, however what happens is that the tests attempt to load the initial data which results in a django.db.utils.OperationalError (essentially it attempts to load the data but the tables don't exist).

I've created a github repo of a project that illustrates the issue and contains a trace - see https://github.com/alexhayes/apps-with-migrations-and-initial-data-break-tests

As outlined in the projects readme I would expect that the tests completely ignore the initial_data.* files for apps that have migrations (as migrate does now) and that I have to create a data migration, as outlined in the documentation.

The obvious workaround for this is just remove the initial_data.* files however it's not clear in the documentation that this is the case.

(1) Note, as detailed in my example github project, the migrations are indeed run prior to load data, but they don't seem to be applied.

Change History (2)

comment:1 by Tim Graham, 10 years ago

Resolution: duplicate
Status: newclosed

I believe this should be resolved by #23699 in yet to be released 1.7.2. Can you please test with stable/1.7.x and reopen if not?

comment:2 by Alex Hayes, 10 years ago

I can confirm that this issue has indeed been resolved in 1.7.2.

Note: See TracTickets for help on using tickets.
Back to Top