Opened 7 years ago

Last modified 5 years ago

#16713 new Bug

Fixture loading for tests ignore database specific names

Reported by: brent@… Owned by: nobody
Component: Testing framework Version: 1.3
Severity: Normal Keywords: fixtures, multidb
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


This is either a doc clarification bug, or a real bug. But based on this from the documentation:

Database-specific fixtures
If you are in a multi-database setup, you may have fixture data that you want to load onto one database, but not onto another. In this situation, you can add database identifier into . If your DATABASES setting has a ‘master’ database defined, you can define the fixture mydata.master.json or mydata.master.json.gz. This fixture will only be loaded if you have specified that you want to load data onto the master database.

This does not working during testing though. If you do not set multi_db = True, the fixtures are loaded into 'default' only. If you do set multi_db = True, all fixtures are loaded into all databases. There is no way to load some data into one database and some other data into the second as the above paragraph states.

If this is *really* a bug and just not the expected behavior and/or someone wants the expected behavior to change I could submit a patch. But I don't want to fix something that may not be broken.

Attached is a test project that shows the behavior.

Attachments (1)

fixturetest.tar.gz (19.1 KB) - added by brent@… 7 years ago.
Test Project that show Fixture loading problems

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by brent@…

Attachment: fixturetest.tar.gz added

Test Project that show Fixture loading problems

comment:1 Changed 7 years ago by Aymeric Augustin

Triage Stage: UnreviewedAccepted

This test shows how this feature works:

With the following changes, your tests pass:

--- testapp/	2011-08-28 12:11:44.000000000 +0200
+++ testapp/	2011-08-28 12:11:02.000000000 +0200
@@ -12,7 +12,7 @@
     multi_db = True
-    fixtures = ['people.default.json']
+    fixtures = ['people']
     def test_fixtures_loaded_to_default(self):
@@ -35,7 +35,7 @@
     This should load the one into default only.
-    fixtures = ['people.default.json']
+    fixtures = ['people']
     def test_fixtures_loaded_to_default(self):
@@ -61,7 +61,7 @@
     multi_db = True
-    fixtures = ['people.default.json', 'morepeople.core.json']
+    fixtures = ['people', 'morepeople']
     def test_fixtures_loaded_to_default(self):

I think it's a bug. The docs say it's possible to pass only the "base name" of the fixture and let Django figure out the rest (database, format, compression); they don't say it's mandatory.

comment:2 Changed 5 years ago by anonymous

Any hope of seeing this bug fixed?

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