@@ -844,7 +844,7 @@ def _blocking_wrapper(self, *args: Any, **kwargs: Any) -> NoReturn: # noqa: ARG
844844 '"db" or "transactional_db" fixtures to enable it. '
845845 )
846846
847- def _unblocked_async_only (self , wrapper_self : Any , * args , ** kwargs ) :
847+ def _unblocked_async_only (self , wrapper_self : Any , * args : Any , ** kwargs : Any ) -> None :
848848 __tracebackhide__ = True
849849 from asgiref .sync import SyncToAsync
850850
@@ -860,23 +860,12 @@ def _unblocked_async_only(self, wrapper_self: Any, *args, **kwargs):
860860 if self ._real_ensure_connection is not None :
861861 self ._real_ensure_connection (wrapper_self , * args , ** kwargs )
862862
863- def _unblocked_sync_only (self , wrapper_self : Any , * args , ** kwargs ):
864- __tracebackhide__ = True
865- if threading .current_thread () != threading .main_thread ():
866- raise RuntimeError (
867- "Database access is only allowed in the main thread, "
868- "modify your test fixtures to be sync or use the transactional_db fixture."
869- "See https://pytest-django.readthedocs.io/en/latest/database.html#db-thread-safeguards for more information."
870- )
871- if self ._real_ensure_connection is not None :
872- self ._real_ensure_connection (wrapper_self , * args , ** kwargs )
873-
874- def unblock (self , async_only = False ) -> AbstractContextManager [None ]:
863+ def unblock (self , async_only : bool = False ) -> AbstractContextManager [None ]:
875864 """Enable access to the Django database."""
876865 self ._save_active_wrapper ()
877866 if async_only :
878867
879- def _method (wrapper_self , * args , ** kwargs ) :
868+ def _method (wrapper_self : Any , * args : Any , ** kwargs : Any ) -> None :
880869 return self ._unblocked_async_only (wrapper_self , * args , ** kwargs )
881870
882871 self ._dj_db_wrapper .ensure_connection = _method
0 commit comments