diff --git a/tests/runtests.py b/tests/runtests.py index 14014f4b01..4956832a5b 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -143,6 +143,7 @@ def setup(verbosity, test_labels): bits = bits[:1] test_labels_set.add('.'.join(bits)) + installed_app_names = set(get_installed()) for modpath, module_name in test_modules: if modpath: module_label = '.'.join([modpath, module_name]) @@ -159,16 +160,12 @@ def setup(verbosity, test_labels): module_label == label or module_label.startswith(label + '.') for label in test_labels_set) - installed_app_names = set(get_installed()) if module_found_in_labels and module_label not in installed_app_names: if verbosity >= 2: print("Importing application %s" % module_name) - # HACK. settings.INSTALLED_APPS.append(module_label) - app_config = AppConfig.create(module_label) - apps.app_configs[app_config.label] = app_config - app_config.import_models(apps.all_models[app_config.label]) - apps.clear_cache() + + apps.set_installed_apps(settings.INSTALLED_APPS) return state