#24658 closed Bug (fixed)
Schema tests fail when run in isolation
Reported by: | Claude Paroz | Owned by: | vladiibine |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Because tables are deleted in tearDown
, when running an individual test, the tables are still existing and any create_model
operation fail.
Change History (8)
comment:1 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 10 years ago
comment:3 by , 10 years ago
Resolution: | → needsinfo |
---|---|
Status: | assigned → closed |
comment:4 by , 10 years ago
Also, I ran this on both the 1.8 branch, and the master on the commit f043434174db3432eb63c341573c1ea89ef59b91, with Python version Python 2.7.5+
I'm releasing this ticket, so that someone else can take a look. If you provide more information, I'll check it out from time to time.
comment:5 by , 10 years ago
Claude, could you more details on which tests fail when run in isolation.
I couldn't reproduce with:
./runtests.py schema.tests.SchemaTests --settings=test_postgres
or
./runtests.py schema.tests.SchemaTests.test_creation_deletion
or
./runtests.py schema.tests.SchemaTests.test_creation_deletion schema.tests.SchemaTests.test_fk --settings=test_postgres
comment:6 by , 10 years ago
I found the issue. The problem happens only with tests using the Note model, and the cause is that the Note model misses the apps = new_apps
Meta attribute. I'll fix that ASAP.
I've tried to test your scenario, but I think more information.
I dont know if I understood correctly, but I tried to run just one individual test, and use the SchemaEditor.create_model method to create a new model class, and instantiate it.
Here's my code, what works (I can create a dynamic model within the test and instantiate it - no errors)
from django.test import TestCase
Then from the command line, I ran the test suites with all 3 of these commands:
Please give more details on how you're getting this issue.