Opened 9 years ago

Closed 5 years ago

#24680 closed Cleanup/optimization (duplicate)

In testing, warnings appear when loading database-specific fixtures

Reported by: Zhongyuan Owned by: nobody
Component: Core (Management commands) Version: dev
Severity: Normal Keywords: testing, fixtures, database-specific, warning
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

How to reproduce

settings.py:

DATABASES = {
    'db1': {......},
    'db2': {......}
}

fixtures:
fixtures/data1.db1.json
fixtures/data2.db2.json

tests.py:

class FixtureTestCase(TestCase):
    fixtures = ['data1', 'data2']
    multi_db = True

    def test(self): pass

Expected results
As stated in the doc https://docs.djangoproject.com/en/dev/ref/django-admin/#database-specific-fixtures, "data1" should be loaded into "db1" DB, "data2" should be loaded into "db2".

Real results
Fixtures were loaded correctly. But there were warnings appeared: "UserWarning: No fixture named 'data1' found."; "UserWarning: No fixture named 'data2' found."

As everything was set up as required, warnings should not appear

How it happened
"TestCase._fixture_setup" call "loaddata" command on all database-fixture combinations, like this:

loaddata data1 data2 database=db1
loaddata data1 data2 database=db2

For "db1", "data2" is not found; and for "db2", "data1" is not found. So warnings raised.

I think the implementation of "_fixture_setup" and/or "loaddata" need some change, to make it work perfectly

Change History (2)

comment:1 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Mariusz Felisiak, 5 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #16713.

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