55import functools
66import inspect
77import socket
8- import sys
98import warnings
109
1110import pytest
@@ -17,7 +16,7 @@ class Mode(str, enum.Enum):
1716 LEGACY = "legacy"
1817
1918
20- LEGACY_MODE = pytest . PytestDeprecationWarning (
19+ LEGACY_MODE = DeprecationWarning (
2120 "The 'asyncio_mode' default value will change to 'strict' in future, "
2221 "please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' "
2322 "in pytest configuration file."
@@ -110,21 +109,7 @@ def pytest_configure(config):
110109 "run using an asyncio event loop" ,
111110 )
112111 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 )
128113
129114
130115@pytest .mark .tryfirst
@@ -222,7 +207,7 @@ def pytest_fixture_setup(fixturedef, request):
222207 )
223208 warnings .warn (
224209 LEGACY_ASYNCIO_FIXTURE .format (name = name ),
225- pytest . PytestDeprecationWarning ,
210+ DeprecationWarning ,
226211 )
227212 else :
228213 # asyncio_mode is STRICT,
0 commit comments