Used Apps.clear_cache() in tests that alter the app registry.

This commit is contained in:
Aymeric Augustin 2013-12-29 21:24:40 +01:00
parent 8cfcd801c4
commit 38ce41103f
6 changed files with 8 additions and 8 deletions

View File

@ -21,7 +21,7 @@ class EggLoadingTest(TestCase):
def tearDown(self): def tearDown(self):
apps.all_models['app_loading'] = self._old_models apps.all_models['app_loading'] = self._old_models
apps.get_models.cache_clear() apps.clear_cache()
sys.path = self.old_path sys.path = self.old_path

View File

@ -128,7 +128,7 @@ class ManagersRegressionTests(TestCase):
finally: finally:
apps.app_configs['managers_regress'].models = _old_models apps.app_configs['managers_regress'].models = _old_models
apps.all_models['managers_regress'] = _old_models apps.all_models['managers_regress'] = _old_models
apps.get_models.cache_clear() apps.clear_cache()
@override_settings(TEST_SWAPPABLE_MODEL='managers_regress.Parent') @override_settings(TEST_SWAPPABLE_MODEL='managers_regress.Parent')
def test_custom_swappable_manager(self): def test_custom_swappable_manager(self):
@ -156,7 +156,7 @@ class ManagersRegressionTests(TestCase):
finally: finally:
apps.app_configs['managers_regress'].models = _old_models apps.app_configs['managers_regress'].models = _old_models
apps.all_models['managers_regress'] = _old_models apps.all_models['managers_regress'] = _old_models
apps.get_models.cache_clear() apps.clear_cache()
@override_settings(TEST_SWAPPABLE_MODEL='managers_regress.Parent') @override_settings(TEST_SWAPPABLE_MODEL='managers_regress.Parent')
def test_explicit_swappable_manager(self): def test_explicit_swappable_manager(self):
@ -184,7 +184,7 @@ class ManagersRegressionTests(TestCase):
finally: finally:
apps.app_configs['managers_regress'].models = _old_models apps.app_configs['managers_regress'].models = _old_models
apps.all_models['managers_regress'] = _old_models apps.all_models['managers_regress'] = _old_models
apps.get_models.cache_clear() apps.clear_cache()
def test_regress_3871(self): def test_regress_3871(self):
related = RelatedModel.objects.create() related = RelatedModel.objects.create()

View File

@ -136,7 +136,7 @@ class MakeMigrationsTests(MigrationTestBase):
def tearDown(self): def tearDown(self):
apps.app_configs['migrations'].models = self._old_models apps.app_configs['migrations'].models = self._old_models
apps.all_models['migrations'] = self._old_models apps.all_models['migrations'] = self._old_models
apps.get_models.cache_clear() apps.clear_cache()
os.chdir(self.test_dir) os.chdir(self.test_dir)
try: try:

View File

@ -175,7 +175,7 @@ class ProxyModelTests(TestCase):
finally: finally:
apps.app_configs['proxy_models'].models = _old_models apps.app_configs['proxy_models'].models = _old_models
apps.all_models['proxy_models'] = _old_models apps.all_models['proxy_models'] = _old_models
apps.get_models.cache_clear() apps.clear_cache()
def test_myperson_manager(self): def test_myperson_manager(self):
Person.objects.create(name="fred") Person.objects.create(name="fred")

View File

@ -168,7 +168,7 @@ def setup(verbosity, test_labels):
app_config = AppConfig.create(module_label) app_config = AppConfig.create(module_label)
app_config.import_models(apps.all_models[app_config.label]) app_config.import_models(apps.all_models[app_config.label])
apps.app_configs[app_config.label] = app_config apps.app_configs[app_config.label] = app_config
apps.get_models.cache_clear() apps.clear_cache()
return state return state

View File

@ -37,7 +37,7 @@ class TablespacesTests(TestCase):
apps.app_configs['tablespaces'].models = self._old_models apps.app_configs['tablespaces'].models = self._old_models
apps.all_models['tablespaces'] = self._old_models apps.all_models['tablespaces'] = self._old_models
apps.get_models.cache_clear() apps.clear_cache()
def assertNumContains(self, haystack, needle, count): def assertNumContains(self, haystack, needle, count):
real_count = haystack.count(needle) real_count = haystack.count(needle)