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):
513
513
def _django_setup_unittest (request , django_db_blocker ):
514
514
"""Setup a django unittest, internal to pytest-django."""
515
515
if not django_settings_is_configured () or not is_django_unittest (request ):
516
+ yield
516
517
return
517
518
518
519
request .getfixturevalue ("django_db_setup" )
519
520
520
- django_db_blocker .unblock ()
521
-
522
521
cls = request .node .cls
523
522
524
523
# implement missing (as of 1.10) debug() method for django's TestCase
@@ -537,19 +536,18 @@ def _cleaning_debug(self):
537
536
538
537
cls .debug = _cleaning_debug
539
538
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
544
546
545
- def teardown ():
546
547
_restore_class_methods (cls )
547
548
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
553
551
554
552
555
553
@pytest .fixture (scope = "function" , autouse = True )
You can’t perform that action at this time.
0 commit comments