@@ -211,7 +211,7 @@ def test_repr_with_no_name(self, mocker: MockerFixture) -> None:
211211 def test_repr_with_name (self , mocker : MockerFixture ) -> None :
212212 test_name = "funny walk"
213213 stub = mocker .stub (name = test_name )
214- assert "name={!r}" . format ( test_name ) in repr (stub )
214+ assert f "name={ test_name !r} " in repr (stub )
215215
216216 def __test_failure_message (self , mocker : MockerFixture , ** kwargs : Any ) -> None :
217217 expected_name = kwargs .get ("name" ) or "mock"
@@ -267,19 +267,19 @@ def test_instance_method_spy_exception(
267267) -> None :
268268 class Foo :
269269 def bar (self , arg ):
270- raise exc_cls ("Error with {}" . format ( arg ) )
270+ raise exc_cls (f "Error with { arg } " )
271271
272272 foo = Foo ()
273273 spy = mocker .spy (foo , "bar" )
274274
275275 expected_calls = []
276276 for i , v in enumerate ([10 , 20 ]):
277- with pytest .raises (exc_cls , match = "Error with {}" . format ( v ) ):
277+ with pytest .raises (exc_cls , match = f "Error with { v } " ):
278278 foo .bar (arg = v )
279279
280280 expected_calls .append (mocker .call (arg = v ))
281281 assert foo .bar .call_args_list == expected_calls # type:ignore[attr-defined]
282- assert str (spy .spy_exception ) == "Error with {}" . format ( v )
282+ assert str (spy .spy_exception ) == f "Error with { v } "
283283
284284
285285def test_instance_method_spy_autospec_true (mocker : MockerFixture ) -> None :
@@ -296,7 +296,7 @@ def bar(self, arg):
296296
297297
298298def test_spy_reset (mocker : MockerFixture ) -> None :
299- class Foo ( object ) :
299+ class Foo :
300300 def bar (self , x ):
301301 if x == 0 :
302302 raise ValueError ("invalid x" )
@@ -475,7 +475,6 @@ def __call__(self, x):
475475 assert spy .spy_return == 20
476476
477477
478- @pytest .mark .asyncio
479478async def test_instance_async_method_spy (mocker : MockerFixture ) -> None :
480479 class Foo :
481480 async def bar (self , arg ):
@@ -728,6 +727,12 @@ def test_foo(mocker):
728727@pytest .mark .usefixtures ("needs_assert_rewrite" )
729728def test_detailed_introspection (testdir : Any ) -> None :
730729 """Check that the "mock_use_standalone" is being used."""
730+ testdir .makeini (
731+ """
732+ [pytest]
733+ asyncio_mode=auto
734+ """
735+ )
731736 testdir .makepyfile (
732737 """
733738 def test(mocker):
@@ -769,11 +774,16 @@ def test(mocker):
769774@pytest .mark .usefixtures ("needs_assert_rewrite" )
770775def test_detailed_introspection_async (testdir : Any ) -> None :
771776 """Check that the "mock_use_standalone" is being used."""
777+ testdir .makeini (
778+ """
779+ [pytest]
780+ asyncio_mode=auto
781+ """
782+ )
772783 testdir .makepyfile (
773784 """
774785 import pytest
775786
776- @pytest.mark.asyncio
777787 async def test(mocker):
778788 m = mocker.AsyncMock()
779789 await m('fo')
@@ -824,6 +834,12 @@ def test_assert_called_with_unicode_arguments(mocker: MockerFixture) -> None:
824834
825835def test_plain_stopall (testdir : Any ) -> None :
826836 """patch.stopall() in a test should not cause an error during unconfigure (#137)"""
837+ testdir .makeini (
838+ """
839+ [pytest]
840+ asyncio_mode=auto
841+ """
842+ )
827843 testdir .makepyfile (
828844 """
829845 import random
@@ -958,6 +974,12 @@ def test_foo(mocker):
958974
959975
960976def test_used_with_class_scope (testdir : Any ) -> None :
977+ testdir .makeini (
978+ """
979+ [pytest]
980+ asyncio_mode=auto
981+ """
982+ )
961983 testdir .makepyfile (
962984 """
963985 import pytest
@@ -982,6 +1004,12 @@ def test_get_random_number(self):
9821004
9831005
9841006def test_used_with_module_scope (testdir : Any ) -> None :
1007+ testdir .makeini (
1008+ """
1009+ [pytest]
1010+ asyncio_mode=auto
1011+ """
1012+ )
9851013 testdir .makepyfile (
9861014 """
9871015 import pytest
@@ -1004,7 +1032,12 @@ def test_get_random_number():
10041032
10051033
10061034def test_used_with_package_scope (testdir : Any ) -> None :
1007- """..."""
1035+ testdir .makeini (
1036+ """
1037+ [pytest]
1038+ asyncio_mode=auto
1039+ """
1040+ )
10081041 testdir .makepyfile (
10091042 """
10101043 import pytest
@@ -1027,7 +1060,12 @@ def test_get_random_number():
10271060
10281061
10291062def test_used_with_session_scope (testdir : Any ) -> None :
1030- """..."""
1063+ testdir .makeini (
1064+ """
1065+ [pytest]
1066+ asyncio_mode=auto
1067+ """
1068+ )
10311069 testdir .makepyfile (
10321070 """
10331071 import pytest
0 commit comments