Opened 4 years ago

Last modified 4 years ago

#24680 new Cleanup/optimization

In testing, warnings appear when loading database-specific fixtures

Reported by: Zhongyuan Owned by: nobody
Component: Core (Management commands) Version: master
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


How to reproduce

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


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

    def test(self): pass

Expected results
As stated in the doc, "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 (1)

comment:1 Changed 4 years ago by Tim Graham

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