diff options
| author | Tim Graham <timograham@gmail.com> | 2018-04-14 07:18:33 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-04-14 07:18:33 -0400 |
| commit | 4a20aae4687df13bf4d81c120c57a88dfb468600 (patch) | |
| tree | 7d0eba2fec29494fac91014b8365cb706df904f0 /tests | |
| parent | f89b11b879b83aa505dc8231da5f06ca4b1b062e (diff) | |
[1.11.x] Added isolated_local_models support to schema tests.
Follow up to 46496a542c2ff9f273e090073e9c8071acb1a4a4, which otherwise
has no effect.
Partial backport of 9f7772e098439f9edea3d25ab127539fc514eeb2 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/schema/tests.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 7108977c2b..96198bad88 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -59,6 +59,9 @@ class SchemaTests(TransactionTestCase): # local_models should contain test dependent model classes that will be # automatically removed from the app cache on test tear down. self.local_models = [] + # isolated_local_models contains models that are in test methods + # decorated with @isolate_apps. + self.isolated_local_models = [] def tearDown(self): # Delete any tables made for our models @@ -73,6 +76,10 @@ class SchemaTests(TransactionTestCase): if through and through._meta.auto_created: del new_apps.all_models['schema'][through._meta.model_name] del new_apps.all_models['schema'][model._meta.model_name] + if self.isolated_local_models: + with connection.schema_editor() as editor: + for model in self.isolated_local_models: + editor.delete_model(model) def delete_tables(self): "Deletes all model tables for our models for a clean test environment" |
