MCPcopy
hub / github.com/django/django / _pre_setup

Method _pre_setup

django/test/testcases.py:1146–1182  ·  view source on GitHub ↗

Perform pre-test setup: * If the class has an 'available_apps' attribute, restrict the app registry to these applications, then fire the post_migrate signal -- it must run with the correct set of applications for the test case. * If the class has a 'fixtu

(cls)

Source from the content-addressed store, hash-verified

1144
1145 @classmethod
1146 def _pre_setup(cls):
1147 """
1148 Perform pre-test setup:
1149 * If the class has an 'available_apps' attribute, restrict the app
1150 registry to these applications, then fire the post_migrate signal --
1151 it must run with the correct set of applications for the test case.
1152 * If the class has a 'fixtures' attribute, install those fixtures.
1153 """
1154 super()._pre_setup()
1155 if cls.available_apps is not None:
1156 apps.set_available_apps(cls.available_apps)
1157 cls._available_apps_calls_balanced += 1
1158 setting_changed.send(
1159 sender=settings._wrapped.__class__,
1160 setting="INSTALLED_APPS",
1161 value=cls.available_apps,
1162 enter=True,
1163 )
1164 for db_name in cls._databases_names(include_mirrors=False):
1165 emit_post_migrate_signal(verbosity=0, interactive=False, db=db_name)
1166 try:
1167 cls._fixture_setup()
1168 except Exception:
1169 if cls.available_apps is not None:
1170 apps.unset_available_apps()
1171 setting_changed.send(
1172 sender=settings._wrapped.__class__,
1173 setting="INSTALLED_APPS",
1174 value=settings.INSTALLED_APPS,
1175 enter=False,
1176 )
1177 raise
1178 # Clear the queries_log so that it's less likely to overflow (a single
1179 # test probably won't execute 9K queries). If queries_log overflows,
1180 # then assertNumQueries() doesn't work.
1181 for db_name in cls._databases_names(include_mirrors=False):
1182 connections[db_name].queries_log.clear()
1183
1184 @classmethod
1185 def _databases_names(cls, include_mirrors=True):

Callers

nothing calls this directly

Calls 8

emit_post_migrate_signalFunction · 0.90
set_available_appsMethod · 0.80
_databases_namesMethod · 0.80
unset_available_appsMethod · 0.80
_pre_setupMethod · 0.45
sendMethod · 0.45
_fixture_setupMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected