File tree 3 files changed +71
-0
lines changed
3 files changed +71
-0
lines changed Original file line number Diff line number Diff line change 1
1
CHANGES
2
2
=======
3
3
4
+ 1.0.2 (2022-01-20)
5
+ ------------------
6
+
7
+ - Restore implicit switch to ``asyncio_mode = auto `` if *legacy * mode is detected.
8
+
4
9
1.0.1 (2022-01-20)
5
10
------------------
6
11
Original file line number Diff line number Diff line change 10
10
AiohttpClient = Callable [[Union [Application , BaseTestServer ]], Awaitable [TestClient ]]
11
11
12
12
13
+ LEGACY_MODE = DeprecationWarning (
14
+ "The 'asyncio_mode' is 'legacy', switching to 'auto' for the sake of "
15
+ "pytest-aiohttp backward compatibility. "
16
+ "Please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' "
17
+ "in pytest configuration file."
18
+ )
19
+
20
+
21
+ @pytest .mark .tryfirst
22
+ def pytest_configure (config ) -> None :
23
+ val = config .getoption ("asyncio_mode" )
24
+ if val is None :
25
+ val = config .getini ("asyncio_mode" )
26
+ if val == "legacy" :
27
+ config .option .asyncio_mode = "auto"
28
+ config .issue_config_time_warning (LEGACY_MODE , stacklevel = 2 )
29
+
30
+
13
31
@pytest .fixture
14
32
def loop (event_loop : asyncio .AbstractEventLoop ) -> asyncio .AbstractEventLoop :
15
33
warnings .warn (
Original file line number Diff line number Diff line change
1
+ from typing import Any
2
+
3
+ from pytest_aiohttp .plugin import LEGACY_MODE
4
+
5
+ pytest_plugins : str = "pytester"
6
+
7
+
8
+ def test_warning_for_legacy_mode (testdir : Any ) -> None :
9
+ testdir .makepyfile (
10
+ """\
11
+ async def test_a():
12
+ pass
13
+
14
+ """
15
+ )
16
+ result = testdir .runpytest_subprocess ("--asyncio-mode=legacy" )
17
+ result .assert_outcomes (passed = 1 )
18
+ result .stdout .fnmatch_lines (["*" + str (LEGACY_MODE ) + "*" ])
19
+
20
+
21
+ def test_auto_mode (testdir : Any ) -> None :
22
+ testdir .makepyfile (
23
+ """\
24
+ async def test_a():
25
+ pass
26
+
27
+ """
28
+ )
29
+ result = testdir .runpytest_subprocess ("--asyncio-mode=auto" )
30
+ result .assert_outcomes (passed = 1 )
31
+ result .stdout .no_fnmatch_line ("*" + str (LEGACY_MODE ) + "*" )
32
+
33
+
34
+ def test_strict_mode (testdir : Any ) -> None :
35
+ testdir .makepyfile (
36
+ """\
37
+ import pytest
38
+
39
+
40
+ @pytest.mark.asyncio
41
+ async def test_a():
42
+ pass
43
+
44
+ """
45
+ )
46
+ result = testdir .runpytest_subprocess ("--asyncio-mode=strict" )
47
+ result .assert_outcomes (passed = 1 )
48
+ result .stdout .no_fnmatch_line ("*" + str (LEGACY_MODE ) + "*" )
You can’t perform that action at this time.
0 commit comments