MCPcopy
hub / github.com/django/django / tearDown

Method tearDown

tests/schema/tests.py:146–162  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

144 self.isolated_local_models = []
145
146 def tearDown(self):
147 # Delete any tables made for our models
148 self.delete_tables()
149 new_apps.clear_cache()
150 for model in new_apps.get_models():
151 model._meta._expire_cache()
152 if "schema" in new_apps.all_models:
153 for model in self.local_models:
154 for many_to_many in model._meta.many_to_many:
155 through = many_to_many.remote_field.through
156 if through and through._meta.auto_created:
157 del new_apps.all_models["schema"][through._meta.model_name]
158 del new_apps.all_models["schema"][model._meta.model_name]
159 if self.isolated_local_models:
160 with connection.schema_editor() as editor:
161 for model in self.isolated_local_models:
162 editor.delete_model(model)
163
164 def delete_tables(self):
165 "Deletes all model tables for our models for a clean test environment"

Callers

nothing calls this directly

Calls 6

delete_tablesMethod · 0.95
_expire_cacheMethod · 0.80
schema_editorMethod · 0.80
clear_cacheMethod · 0.45
get_modelsMethod · 0.45
delete_modelMethod · 0.45

Tested by

no test coverage detected