Code

Opened 4 years ago

Last modified 16 months 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

Description

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 http://code.djangoproject.com/browser/django/trunk/django/core/management/commands/loaddata.py#L196

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

Attachments (0)

Change History (5)

comment:1 Changed 3 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 3 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 3 years ago by anonymous

  • Severity set to Normal
  • Type set to Bug

comment:4 Changed 3 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 16 months ago by aaugustin

  • Status changed from reopened to new

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.