Opened 14 years ago

Closed 5 years ago

#15063 closed Bug (duplicate)

multi_db flag on TestCase causes invalid error reporting when loading fixtures.

Reported by: David Cramer 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)

Change History (6)

comment:1 by Russell Keith-Magee, 14 years ago

Resolution: invalid
Status: newclosed

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 by Russell Keith-Magee, 14 years ago

Component: UncategorizedTesting framework
Resolution: invalid
Status: closedreopened
Triage Stage: UnreviewedAccepted

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 by anonymous, 14 years ago

Severity: Normal
Type: Bug

comment:4 by Ramiro Morales, 13 years ago

Easy pickings: unset
Summary: multi_db flag on TestCase causes invalid error reportingmulti_db flag on TestCase causes invalid error reporting when loading fixtures
UI/UX: unset

comment:5 by Aymeric Augustin, 12 years ago

Status: reopenednew

comment:6 by Mariusz Felisiak, 5 years ago

Resolution: duplicate
Status: newclosed
Summary: multi_db flag on TestCase causes invalid error reporting when loading fixturesmulti_db flag on TestCase causes invalid error reporting when loading fixtures.

As far as I'm concerned this is a duplicate of #16713.

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