MCPcopy
hub / github.com/django/django / _setup_and_call

Method _setup_and_call

django/test/testcases.py:338–377  ·  view source on GitHub ↗

Perform the following in order: pre-setup, run test, post-teardown, skipping pre/post hooks if test is set to be skipped. If debug=True, reraise any errors in setup and use super().debug() instead of __call__() to run the test.

(self, result, debug=False)

Source from the content-addressed store, hash-verified

336 self._setup_and_call(debug_result, debug=True)
337
338 def _setup_and_call(self, result, debug=False):
339 """
340 Perform the following in order: pre-setup, run test, post-teardown,
341 skipping pre/post hooks if test is set to be skipped.
342
343 If debug=True, reraise any errors in setup and use super().debug()
344 instead of __call__() to run the test.
345 """
346 testMethod = getattr(self, self._testMethodName)
347 skipped = getattr(self.__class__, "__unittest_skip__", False) or getattr(
348 testMethod, "__unittest_skip__", False
349 )
350
351 # Convert async test methods.
352 if iscoroutinefunction(testMethod):
353 setattr(self, self._testMethodName, async_to_sync(testMethod))
354
355 if not skipped:
356 try:
357 if self.__class__._pre_setup_ran_eagerly:
358 self.__class__._pre_setup_ran_eagerly = False
359 else:
360 self._pre_setup()
361 except Exception:
362 if debug:
363 raise
364 result.addError(self, sys.exc_info())
365 return
366 if debug:
367 super().debug()
368 else:
369 super().__call__(result)
370 if not skipped:
371 try:
372 self._post_teardown()
373 except Exception:
374 if debug:
375 raise
376 result.addError(self, sys.exc_info())
377 return
378
379 @classmethod
380 def _pre_setup(cls):

Callers 2

__call__Method · 0.95
debugMethod · 0.95

Calls 5

_pre_setupMethod · 0.95
_post_teardownMethod · 0.95
addErrorMethod · 0.45
debugMethod · 0.45
__call__Method · 0.45

Tested by

no test coverage detected