Opened 6 years ago

Last modified 3 years ago

#15063 new Bug

multi_db flag on TestCase causes invalid error reporting when loading fixtures

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


When setting multi_db = True on a test case you may encounter aliases which do not allow synchronization with specific tables. Due to the behavior of the fixture loader, it sees that no objects were loaded for these specific aliases and prints an exception to stderr and runs a rollback command.

The chunk of code in reference is here

(For posterity, the 'if objects_in_fixture == 0:' error assumption is what causes this behavior)

Change History (5)

comment:1 Changed 6 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

You appear to be describing a situation where a test database can't synchronize all the tables it should have, and as a result, fixture loading fails.

For my money, that situation *should* raise errors.

I'm not sure I see how this is related to multi-db. Setting multi-db=True increases the number of databases that will be synchronized, but it doesn't change the way individual databases are synchronized. If you get this problem with multi-db, you should be able to reproduce it with a single database under the right conditions.

Closing invalid; if I've missed the point, feel free to reopen and provide more detail. For the record, you should also feel free to provide sufficient detail when you open a ticket in the first place :-)

comment:2 Changed 6 years ago by russellm

  • Component changed from Uncategorized to Testing framework
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Triage Stage changed from Unreviewed to Accepted

Following discussion with David on IRC:

The actual problem here is a fixture that contains many valid objects, being synchronized onto a database where none of the models for those objects exist. E.g., I have a fixture with 10 Author objects; the Author table isn't synchronized onto 'other', but I'm loading Author onto 'other'. There are 10 valid objects, but 0 "loaded" objects, which raises an error during test case fixture loading.

comment:3 Changed 5 years ago by anonymous

  • Severity set to Normal
  • Type set to Bug

comment:4 Changed 5 years ago by ramiro

  • Easy pickings unset
  • Summary changed from multi_db flag on TestCase causes invalid error reporting to multi_db flag on TestCase causes invalid error reporting when loading fixtures
  • UI/UX unset

comment:5 Changed 3 years ago by aaugustin

  • Status changed from reopened to new
Note: See TracTickets for help on using tickets.
Back to Top