diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index 1fefdff41..3a9c49b92 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -13,6 +13,7 @@ from __future__ import annotations import inspect from pathlib import Path +from typing import Any from warnings import warn from warnings import warn_explicit @@ -94,7 +95,7 @@ def check_ispytest(ispytest: bool) -> None: warn(PRIVATE, stacklevel=3) -def _warn_auto_stacklevel(message, category=UserWarning): +def _warn_auto_stacklevel(message: Warning | str, category: Any = UserWarning) -> None: """Emit a warning with trace outside the pytest namespace.""" root_dir = Path(__file__).parents[1] frame = inspect.currentframe() diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index 4c9248010..803a62ffc 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -196,7 +196,7 @@ def test_fixture_disallow_on_marked_functions(): @pytest.mark.parametrize("example", ["hello"]) @pytest.fixture - def foo(): + def bar(): raise NotImplementedError() assert len(record) == 1