mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Made runtests.py use 'set_installed_apps' API
This will also trigger the ready method of any tested application, which was not run before.
This commit is contained in:
parent
f01d2a8f9b
commit
19b4908206
@ -143,6 +143,7 @@ def setup(verbosity, test_labels):
|
|||||||
bits = bits[:1]
|
bits = bits[:1]
|
||||||
test_labels_set.add('.'.join(bits))
|
test_labels_set.add('.'.join(bits))
|
||||||
|
|
||||||
|
installed_app_names = set(get_installed())
|
||||||
for modpath, module_name in test_modules:
|
for modpath, module_name in test_modules:
|
||||||
if modpath:
|
if modpath:
|
||||||
module_label = '.'.join([modpath, module_name])
|
module_label = '.'.join([modpath, module_name])
|
||||||
@ -159,16 +160,12 @@ def setup(verbosity, test_labels):
|
|||||||
module_label == label or module_label.startswith(label + '.')
|
module_label == label or module_label.startswith(label + '.')
|
||||||
for label in test_labels_set)
|
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 module_found_in_labels and module_label not in installed_app_names:
|
||||||
if verbosity >= 2:
|
if verbosity >= 2:
|
||||||
print("Importing application %s" % module_name)
|
print("Importing application %s" % module_name)
|
||||||
# HACK.
|
|
||||||
settings.INSTALLED_APPS.append(module_label)
|
settings.INSTALLED_APPS.append(module_label)
|
||||||
app_config = AppConfig.create(module_label)
|
|
||||||
apps.app_configs[app_config.label] = app_config
|
apps.set_installed_apps(settings.INSTALLED_APPS)
|
||||||
app_config.import_models(apps.all_models[app_config.label])
|
|
||||||
apps.clear_cache()
|
|
||||||
|
|
||||||
return state
|
return state
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user