File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -513,12 +513,11 @@ def _django_db_marker(request):
513513def _django_setup_unittest (request , django_db_blocker ):
514514 """Setup a django unittest, internal to pytest-django."""
515515 if not django_settings_is_configured () or not is_django_unittest (request ):
516+ yield
516517 return
517518
518519 request .getfixturevalue ("django_db_setup" )
519520
520- django_db_blocker .unblock ()
521-
522521 cls = request .node .cls
523522
524523 # implement missing (as of 1.10) debug() method for django's TestCase
@@ -537,19 +536,18 @@ def _cleaning_debug(self):
537536
538537 cls .debug = _cleaning_debug
539538
540- if _handle_unittest_methods :
541- _restore_class_methods (cls )
542- cls .setUpClass ()
543- _disable_class_methods (cls )
539+ with django_db_blocker .unblock ():
540+ if _handle_unittest_methods :
541+ _restore_class_methods (cls )
542+ cls .setUpClass ()
543+ _disable_class_methods (cls )
544+
545+ yield
544546
545- def teardown ():
546547 _restore_class_methods (cls )
547548 cls .tearDownClass ()
548- django_db_blocker .restore ()
549-
550- request .addfinalizer (teardown )
551- else :
552- request .addfinalizer (django_db_blocker .restore )
549+ else :
550+ yield
553551
554552
555553@pytest .fixture (scope = "function" , autouse = True )
You can’t perform that action at this time.
0 commit comments