11from textwrap import dedent
22
3+ from pytest import Pytester
34
4- def test_strict_mode_cmdline (testdir ):
5- testdir .makepyfile (
5+
6+ def test_strict_mode_cmdline (pytester : Pytester ):
7+ pytester .makepyfile (
68 dedent (
79 """\
810 import asyncio
@@ -16,12 +18,12 @@ async def test_a():
1618 """
1719 )
1820 )
19- result = testdir .runpytest ("--asyncio-mode=strict" )
21+ result = pytester .runpytest ("--asyncio-mode=strict" )
2022 result .assert_outcomes (passed = 1 )
2123
2224
23- def test_strict_mode_cfg (testdir ):
24- testdir .makepyfile (
25+ def test_strict_mode_cfg (pytester : Pytester ):
26+ pytester .makepyfile (
2527 dedent (
2628 """\
2729 import asyncio
@@ -35,13 +37,13 @@ async def test_a():
3537 """
3638 )
3739 )
38- testdir .makefile (".ini" , pytest = "[pytest]\n asyncio_mode = strict\n " )
39- result = testdir .runpytest ()
40+ pytester .makefile (".ini" , pytest = "[pytest]\n asyncio_mode = strict\n " )
41+ result = pytester .runpytest ()
4042 result .assert_outcomes (passed = 1 )
4143
4244
43- def test_strict_mode_method_fixture (testdir ):
44- testdir .makepyfile (
45+ def test_strict_mode_method_fixture (pytester : Pytester ):
46+ pytester .makepyfile (
4547 dedent (
4648 """\
4749 import asyncio
@@ -64,12 +66,12 @@ async def test_a(self, fixture_a):
6466 """
6567 )
6668 )
67- result = testdir .runpytest ("--asyncio-mode=auto" )
69+ result = pytester .runpytest ("--asyncio-mode=auto" )
6870 result .assert_outcomes (passed = 1 )
6971
7072
71- def test_strict_mode_ignores_unmarked_coroutine (testdir ):
72- testdir .makepyfile (
73+ def test_strict_mode_ignores_unmarked_coroutine (pytester : Pytester ):
74+ pytester .makepyfile (
7375 dedent (
7476 """\
7577 import pytest
@@ -79,13 +81,13 @@ async def test_anything():
7981 """
8082 )
8183 )
82- result = testdir .runpytest_subprocess ("--asyncio-mode=strict" , "-W default" )
84+ result = pytester .runpytest_subprocess ("--asyncio-mode=strict" , "-W default" )
8385 result .assert_outcomes (skipped = 1 , warnings = 1 )
8486 result .stdout .fnmatch_lines (["*async def functions are not natively supported*" ])
8587
8688
87- def test_strict_mode_ignores_unmarked_fixture (testdir ):
88- testdir .makepyfile (
89+ def test_strict_mode_ignores_unmarked_fixture (pytester : Pytester ):
90+ pytester .makepyfile (
8991 dedent (
9092 """\
9193 import pytest
@@ -100,7 +102,7 @@ async def test_anything(any_fixture):
100102 """
101103 )
102104 )
103- result = testdir .runpytest_subprocess ("--asyncio-mode=strict" , "-W default" )
105+ result = pytester .runpytest_subprocess ("--asyncio-mode=strict" , "-W default" )
104106 result .assert_outcomes (skipped = 1 , warnings = 2 )
105107 result .stdout .fnmatch_lines (
106108 [
0 commit comments