Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25745 closed Bug (fixed)

Fix RuntimeWarnings about model reloading in test suite

Reported by: Tim Graham Owned by: Simon Charette
Component: Core (Other) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Similar warnings to those reported in #24812 are back in several apps: order_with_respect_to, foreign_object, schema.

To see the order_with_respect_to warnings, you must also include contenttypes_tests (these apps share models):
$ python -Wall runtests.py order_with_respect_to contenttypes_tests

Example:

/home/tim/code/django/django/db/models/base.py:283: RuntimeWarning: Model 'order_with_respect_to.bar' was already registered. Reloading models is not advised as it can lead to inconsistencies, most notably with related models.

We should probably promote RuntimeWarning to "error" in tests/runtests.py to prevent future regressions.

Change History (20)

comment:1 by Simon Charette, 9 years ago

I wonder if the order_with_respect_to and foreign_object issues are fixed by the following commits:

https://github.com/charettes/django/commit/836c19a2b64e8324fa792104fddb434e29be125c
https://github.com/charettes/django/commit/8eb98a0809229e635d1603c19314ac4c383d9ead

which are part of this PR.

comment:2 by Simon Charette, 9 years ago

I confirm that the issues are fixed by the proposed commits.

comment:3 by Simon Charette, 9 years ago

The schema tests will need a bit of adjustment to avoid registering the LocalTagThrough model multiple time to the same apps instance (see SchemaTests._test_m2m_create_through).

comment:4 by Simon Charette, 9 years ago

Tim what do you think of closing this ticket in favor of #25746?

Maybe we should reuse this one for the sole purpose of promoting RuntimeWarning to errors?

Last edited 9 years ago by Simon Charette (previous) (diff)

comment:5 by Tim Graham, 9 years ago

I'd appreciate (perhaps simpler) patches we could backport to 1.9 and 1.8 (schema only).

Last edited 9 years ago by Tim Graham (previous) (diff)

comment:6 by Simon Charette, 9 years ago

Owner: changed from nobody to Simon Charette
Status: newassigned

comment:7 by Simon Charette, 9 years ago

Has patch: set

comment:8 by Tim Graham, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:9 by Simon Charette <charette.s@…>, 9 years ago

In 406de4c:

Refs #25745 -- Isolated an order_with_respect_to test.

comment:10 by Simon Charette <charette.s@…>, 9 years ago

In 2eefbca:

Refs #25745 -- Isolated a foreign_object test.

comment:11 by Simon Charette <charette.s@…>, 9 years ago

In 64240263:

Refs #25745 -- Avoided multiple registration of the same model in schema tests.

comment:12 by Simon Charette <charette.s@…>, 9 years ago

In d95b22b:

Refs #25745 -- Isolated some postgres array field check tests.

comment:13 by Simon Charette <charette.s@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 1c5f4e86:

Fixed #25745 -- Promoted RuntimeWarnings to errors in the test suite.

comment:14 by Simon Charette <charette.s@…>, 9 years ago

In e8512811:

[1.9.x] Refs #25745 -- Isolated an order_with_respect_to test.

Backport of 406de4c243e3618c13c36c23e07a4aa33162b344 from master

comment:15 by Simon Charette <charette.s@…>, 9 years ago

In fb016e6:

[1.9.x] Refs #25745 -- Isolated a foreign_object test.

Backport of 2eefbca1a4140d8a8174a06a1f0160fcc76d8f64 from master

comment:16 by Simon Charette <charette.s@…>, 9 years ago

In 77e5790:

[1.9.x] Refs #25745 -- Avoided multiple registration of the same model in schema tests.

Backport of 64240263f22055cb539159e9359e64d5096f39d9 from master

comment:17 by Simon Charette <charette.s@…>, 9 years ago

In cfa3d4a2:

[1.9.x] Refs #25745 -- Isolated some postgres array field check tests.

Backport of d95b22bd56764c71047ec16f628c00c0fd997cfd from master

comment:18 by Simon Charette <charette.s@…>, 9 years ago

In ef78aec2:

[1.9.x] Fixed #25745 -- Promoted RuntimeWarnings to errors in the test suite.

Backport of 1c5f4e86bc9c7bae5d5f3830d9cfbb0043297261 from master

comment:19 by Simon Charette <charette.s@…>, 9 years ago

In afe84c71:

[1.8.x] Refs #25745 -- Avoided multiple registration of the same model in schema tests.

Conflicts:

tests/schema/tests.py

Backport of 64240263f22055cb539159e9359e64d5096f39d9 from master

comment:20 by Simon Charette <charette.s@…>, 9 years ago

In 5a6a5ce0:

[1.8.x] Fixed #25745 -- Promoted RuntimeWarnings to errors in the test suite.

Conflicts:

tests/apps/tests.py
tests/migrations/test_graph.py
tests/queryset_pickle/tests.py
tests/runtests.py

Backport of 1c5f4e86bc9c7bae5d5f3830d9cfbb0043297261 from master

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