Opened 10 years ago
Closed 10 years ago
#23125 closed Uncategorized (duplicate)
Running test loads initial_data even on migrated app
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Testing framework | Version: | 1.7-rc-2 |
Severity: | Normal | Keywords: | test flush migration |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Documentation says that If an application uses migrations, there is no automatic loading of fixtures.
I think we can expect the same when running tests but it appears not to be the case. After a little investigation I noticed:
- the test command calls the migrate commands with a parameter test_flush set to True: https://github.com/django/django/blob/1.7c2/django/db/backends/creation.py#L374
- the migrate command calls flush command : https://github.com/django/django/blob/1.7c2/django/core/management/commands/migrate.py#L135
- and the flush command runs loaddata with initial_data as a fixture_label : https://github.com/django/django/blob/1.7c2/django/core/management/commands/flush.py#L86
This makes running tests fails as it tries to load data before the tables had been created.
Note:
See TracTickets
for help on using tickets.
Duplicate of #23077