[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2023-02-07 04:47:26 +00:00
parent 0dd682fc2b
commit 894aa333a7
12 changed files with 3 additions and 14 deletions

View File

@ -274,7 +274,6 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
return f.read() return f.read()
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
from importlib.resources.abc import TraversableResources from importlib.resources.abc import TraversableResources
else: else:

View File

@ -62,7 +62,6 @@ from _pytest.warning_types import PytestConfigWarning
from _pytest.warning_types import warn_explicit_for from _pytest.warning_types import warn_explicit_for
if TYPE_CHECKING: if TYPE_CHECKING:
from _pytest._code.code import _TracebackStyle from _pytest._code.code import _TracebackStyle
from _pytest.terminal import TerminalReporter from _pytest.terminal import TerminalReporter
from .argparsing import Argument from .argparsing import Argument
@ -1067,7 +1066,6 @@ class Config:
try: try:
self.parse(args) self.parse(args)
except UsageError: except UsageError:
# Handle --version and --help here in a minimal fashion. # Handle --version and --help here in a minimal fashion.
# This gets done via helpconfig normally, but its # This gets done via helpconfig normally, but its
# pytest_cmdline_main is not called in case of errors. # pytest_cmdline_main is not called in case of errors.

View File

@ -43,7 +43,6 @@ class PathAwareHookProxy:
@_wraps(hook) @_wraps(hook)
def fixed_hook(**kw): def fixed_hook(**kw):
path_value: Optional[Path] = kw.pop(path_var, None) path_value: Optional[Path] = kw.pop(path_var, None)
fspath_value: Optional[LEGACY_PATH] = kw.pop(fspath_var, None) fspath_value: Optional[LEGACY_PATH] = kw.pop(fspath_var, None)
if fspath_value is not None: if fspath_value is not None:

View File

@ -531,7 +531,6 @@ class DoctestModule(Module):
if _is_mocked(obj): if _is_mocked(obj):
return return
with _patch_unwrap_mock_aware(): with _patch_unwrap_mock_aware():
# Type ignored because this is a private function. # Type ignored because this is a private function.
super()._find( # type:ignore[misc] super()._find( # type:ignore[misc]
tests, obj, name, module, source_lines, globs, seen tests, obj, name, module, source_lines, globs, seen

View File

@ -219,7 +219,6 @@ def _resolve_msg_to_reason(
""" """
__tracebackhide__ = True __tracebackhide__ = True
if msg is not None: if msg is not None:
if reason: if reason:
from pytest import UsageError from pytest import UsageError

View File

@ -789,7 +789,8 @@ def _call_with_optional_argument(func, arg) -> None:
def _get_first_non_fixture_func(obj: object, names: Iterable[str]) -> Optional[object]: def _get_first_non_fixture_func(obj: object, names: Iterable[str]) -> Optional[object]:
"""Return the attribute from the given object to be used as a setup/teardown """Return the attribute from the given object to be used as a setup/teardown
xunit-style function, but only if not marked as a fixture to avoid calling it twice.""" xunit-style function, but only if not marked as a fixture to avoid calling it twice.
"""
for name in names: for name in names:
meth: Optional[object] = getattr(obj, name, None) meth: Optional[object] = getattr(obj, name, None)
if meth is not None and fixtures.getfixturemarker(meth) is None: if meth is not None and fixtures.getfixturemarker(meth) is None:

View File

@ -572,7 +572,6 @@ def _report_kwargs_from_json(reportdict: Dict[str, Any]) -> Dict[str, Any]:
and "reprcrash" in reportdict["longrepr"] and "reprcrash" in reportdict["longrepr"]
and "reprtraceback" in reportdict["longrepr"] and "reprtraceback" in reportdict["longrepr"]
): ):
reprtraceback = deserialize_repr_traceback( reprtraceback = deserialize_repr_traceback(
reportdict["longrepr"]["reprtraceback"] reportdict["longrepr"]["reprtraceback"]
) )

View File

@ -871,7 +871,6 @@ class TestDurations:
) )
def test_calls_show_2(self, pytester: Pytester, mock_timing) -> None: def test_calls_show_2(self, pytester: Pytester, mock_timing) -> None:
pytester.makepyfile(self.source) pytester.makepyfile(self.source)
result = pytester.runpytest_inprocess("--durations=2") result = pytester.runpytest_inprocess("--durations=2")
assert result.ret == 0 assert result.ret == 0

View File

@ -494,7 +494,6 @@ class TestLastFailed:
def test_lastfailed_collectfailure( def test_lastfailed_collectfailure(
self, pytester: Pytester, monkeypatch: MonkeyPatch self, pytester: Pytester, monkeypatch: MonkeyPatch
) -> None: ) -> None:
pytester.makepyfile( pytester.makepyfile(
test_maybe=""" test_maybe="""
import os import os

View File

@ -1236,7 +1236,6 @@ class TestDoctestSkips:
class TestDoctestAutoUseFixtures: class TestDoctestAutoUseFixtures:
SCOPES = ["module", "session", "class", "function"] SCOPES = ["module", "session", "class", "function"]
def test_doctest_module_session_fixture(self, pytester: Pytester): def test_doctest_module_session_fixture(self, pytester: Pytester):
@ -1379,7 +1378,6 @@ class TestDoctestAutoUseFixtures:
class TestDoctestNamespaceFixture: class TestDoctestNamespaceFixture:
SCOPES = ["module", "session", "class", "function"] SCOPES = ["module", "session", "class", "function"]
@pytest.mark.parametrize("scope", SCOPES) @pytest.mark.parametrize("scope", SCOPES)

View File

@ -253,7 +253,6 @@ class TestPython:
duration_report: str, duration_report: str,
run_and_parse: RunAndParse, run_and_parse: RunAndParse,
) -> None: ) -> None:
# mock LogXML.node_reporter so it always sets a known duration to each test report object # mock LogXML.node_reporter so it always sets a known duration to each test report object
original_node_reporter = LogXML.node_reporter original_node_reporter = LogXML.node_reporter
@ -603,7 +602,6 @@ class TestPython:
node.assert_attr(failures=3, tests=3) node.assert_attr(failures=3, tests=3)
for index, char in enumerate("<&'"): for index, char in enumerate("<&'"):
tnode = node.find_nth_by_tag("testcase", index) tnode = node.find_nth_by_tag("testcase", index)
tnode.assert_attr( tnode.assert_attr(
classname="test_failure_escape", name="test_func[%s]" % char classname="test_failure_escape", name="test_func[%s]" % char

View File

@ -906,6 +906,7 @@ def test_makereport_getsource_dynamic_code(
def test_store_except_info_on_error() -> None: def test_store_except_info_on_error() -> None:
"""Test that upon test failure, the exception info is stored on """Test that upon test failure, the exception info is stored on
sys.last_traceback and friends.""" sys.last_traceback and friends."""
# Simulate item that might raise a specific exception, depending on `raise_error` class var # Simulate item that might raise a specific exception, depending on `raise_error` class var
class ItemMightRaise: class ItemMightRaise:
nodeid = "item_that_raises" nodeid = "item_that_raises"