@@ -601,32 +601,44 @@ class Migration(migrations.Migration):
601601    assert  result .ret  ==  0 
602602
603603
604- class  Test_django_db_blocker :
605-     @pytest .mark .django_db  
606-     def  test_block_manually (self , django_db_blocker ):
607-         try :
608-             django_db_blocker .block ()
609-             with  pytest .raises (RuntimeError ):
610-                 Item .objects .exists ()
611-         finally :
612-             django_db_blocker .restore ()
604+ def  test_django_db_blocker (testdir ):
605+     p1  =  testdir .makepyfile (""" 
606+         import django.db.utils 
607+         import pytest 
613608
614-     @pytest .mark .django_db  
615-     def  test_block_with_block (self , django_db_blocker ):
616-         with  django_db_blocker .block ():
617-             with  pytest .raises (RuntimeError ):
618-                 Item .objects .exists ()
609+         from pytest_django_test.app.models import Item 
619610
620-     def  test_unblock_manually (self , django_db_blocker ):
621-         try :
622-             django_db_blocker .unblock ()
623-             Item .objects .exists ()
624-         finally :
625-             django_db_blocker .restore ()
626611
627-     def  test_unblock_with_block (self , django_db_blocker ):
628-         with  django_db_blocker .unblock ():
629-             Item .objects .exists ()
612+         @pytest.mark.django_db 
613+         def test_block_manually(django_db_blocker): 
614+             try: 
615+                 django_db_blocker.block() 
616+                 with pytest.raises(RuntimeError): 
617+                     Item.objects.exists() 
618+             finally: 
619+                 django_db_blocker.restore() 
620+ 
621+         @pytest.mark.django_db 
622+         def test_block_with_block(django_db_blocker): 
623+             with django_db_blocker.block(): 
624+                 with pytest.raises(RuntimeError): 
625+                     Item.objects.exists() 
626+ 
627+         def test_unblock_manually(django_db_blocker): 
628+             try: 
629+                 django_db_blocker.unblock() 
630+                 with pytest.raises(django.db.utils.OperationalError): 
631+                     Item.objects.exists() 
632+             finally: 
633+                 django_db_blocker.restore() 
634+ 
635+         def test_unblock_with_block(django_db_blocker): 
636+             with django_db_blocker.unblock(): 
637+                 with pytest.raises(django.db.utils.OperationalError): 
638+                     Item.objects.exists() 
639+     """ )
640+     result  =  testdir .runpytest_subprocess ("-vv" , "-rA" , "--tb=short" , str (p1 ))
641+     assert  result .ret  ==  0 
630642
631643
632644def  test_mail (mailoutbox ):
0 commit comments