5
5
import functools
6
6
import inspect
7
7
import socket
8
- import sys
9
8
import warnings
10
9
11
10
import pytest
@@ -17,7 +16,7 @@ class Mode(str, enum.Enum):
17
16
LEGACY = "legacy"
18
17
19
18
20
- LEGACY_MODE = pytest . PytestDeprecationWarning (
19
+ LEGACY_MODE = DeprecationWarning (
21
20
"The 'asyncio_mode' default value will change to 'strict' in future, "
22
21
"please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' "
23
22
"in pytest configuration file."
@@ -110,21 +109,7 @@ def pytest_configure(config):
110
109
"run using an asyncio event loop" ,
111
110
)
112
111
if _get_asyncio_mode (config ) == Mode .LEGACY :
113
- _issue_warning_captured (LEGACY_MODE , config .hook , stacklevel = 1 )
114
-
115
-
116
- def _issue_warning_captured (warning , hook , * , stacklevel = 1 ):
117
- # copy-paste of pytest internal _pytest.warnings._issue_warning_captured function
118
- with warnings .catch_warnings (record = True ) as records :
119
- warnings .simplefilter ("always" , type (warning ))
120
- warnings .warn (LEGACY_MODE , stacklevel = stacklevel )
121
- frame = sys ._getframe (stacklevel - 1 )
122
- location = frame .f_code .co_filename , frame .f_lineno , frame .f_code .co_name
123
- hook .pytest_warning_recorded .call_historic (
124
- kwargs = dict (
125
- warning_message = records [0 ], when = "config" , nodeid = "" , location = location
126
- )
127
- )
112
+ config .issue_config_time_warning (LEGACY_MODE , stacklevel = 2 )
128
113
129
114
130
115
@pytest .mark .tryfirst
@@ -222,7 +207,7 @@ def pytest_fixture_setup(fixturedef, request):
222
207
)
223
208
warnings .warn (
224
209
LEGACY_ASYNCIO_FIXTURE .format (name = name ),
225
- pytest . PytestDeprecationWarning ,
210
+ DeprecationWarning ,
226
211
)
227
212
else :
228
213
# asyncio_mode is STRICT,
0 commit comments