mirror of https://github.com/pytest-dev/pytest.git
fixup: pre-commit green again
This commit is contained in:
parent
2b16e7b138
commit
e60afd5af2
|
@ -31,6 +31,7 @@ classifiers = [
|
|||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Topic :: Software Development :: Libraries",
|
||||
"Topic :: Software Development :: Testing",
|
||||
"Topic :: Utilities",
|
||||
|
|
|
@ -200,8 +200,8 @@ class TracebackEntry:
|
|||
rawentry: TracebackType,
|
||||
repr_style: Literal["short", "long"] | None = None,
|
||||
) -> None:
|
||||
self._rawentry: "Final" = rawentry
|
||||
self._repr_style: "Final" = repr_style
|
||||
self._rawentry: Final = rawentry
|
||||
self._repr_style: Final = repr_style
|
||||
|
||||
def with_repr_style(
|
||||
self, repr_style: Literal["short", "long"] | None
|
||||
|
|
|
@ -70,6 +70,7 @@ if TYPE_CHECKING:
|
|||
from .argparsing import Argument
|
||||
from .argparsing import Parser
|
||||
from _pytest._code.code import _TracebackStyle
|
||||
from _pytest.cacheprovider import Cache
|
||||
from _pytest.terminal import TerminalReporter
|
||||
|
||||
|
||||
|
@ -1009,6 +1010,8 @@ class Config:
|
|||
object.__setattr__(self, "plugins", plugins)
|
||||
object.__setattr__(self, "dir", dir)
|
||||
|
||||
cache: Cache
|
||||
|
||||
class ArgsSource(enum.Enum):
|
||||
"""Indicates the source of the test arguments.
|
||||
|
||||
|
@ -1084,11 +1087,6 @@ class Config:
|
|||
self.args_source = Config.ArgsSource.ARGS
|
||||
self.args: list[str] = []
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from _pytest.cacheprovider import Cache
|
||||
|
||||
self.cache: Optional[Cache] = None
|
||||
|
||||
@property
|
||||
def rootpath(self) -> pathlib.Path:
|
||||
"""The path to the :ref:`rootdir <rootdir>`.
|
||||
|
@ -1906,7 +1904,7 @@ def parse_warning_filter(
|
|||
parts.append("")
|
||||
action_, message, category_, module, lineno_ = (s.strip() for s in parts)
|
||||
try:
|
||||
action: "warnings._ActionKind" = warnings._getaction(action_) # type: ignore[attr-defined]
|
||||
action: warnings._ActionKind = warnings._getaction(action_) # type: ignore[attr-defined]
|
||||
except warnings._OptionError as e:
|
||||
raise UsageError(error_template.format(error=str(e))) from None
|
||||
try:
|
||||
|
|
|
@ -294,7 +294,7 @@ class DoctestItem(Item):
|
|||
def runtest(self) -> None:
|
||||
_check_all_skipped(self.dtest)
|
||||
self._disable_output_capturing_for_darwin()
|
||||
failures: list["doctest.DocTestFailure"] = []
|
||||
failures: list[doctest.DocTestFailure] = []
|
||||
# Type ignored because we change the type of `out` from what
|
||||
# doctest expects.
|
||||
self.runner.run(self.dtest, out=failures) # type: ignore[arg-type]
|
||||
|
|
|
@ -14,7 +14,6 @@ from typing import AbstractSet
|
|||
from typing import Any
|
||||
from typing import Callable
|
||||
from typing import cast
|
||||
from typing import Dict
|
||||
from typing import Final
|
||||
from typing import final
|
||||
from typing import Generator
|
||||
|
@ -205,7 +204,7 @@ def get_parametrized_fixture_keys(
|
|||
|
||||
|
||||
def reorder_items(items: Sequence[nodes.Item]) -> list[nodes.Item]:
|
||||
argkeys_cache: dict[Scope, dict[nodes.Item, Dict[FixtureArgKey, None]]] = {}
|
||||
argkeys_cache: dict[Scope, dict[nodes.Item, dict[FixtureArgKey, None]]] = {}
|
||||
items_by_argkey: dict[
|
||||
Scope, dict[FixtureArgKey, OrderedDict[nodes.Item, None]]
|
||||
] = {}
|
||||
|
@ -226,8 +225,8 @@ def reorder_items(items: Sequence[nodes.Item]) -> list[nodes.Item]:
|
|||
|
||||
def fix_cache_order(
|
||||
item: nodes.Item,
|
||||
argkeys_cache: Dict[Scope, Dict[nodes.Item, Dict[FixtureArgKey, None]]],
|
||||
items_by_argkey: Dict[Scope, Dict[FixtureArgKey, OrderedDict[nodes.Item, None]]],
|
||||
argkeys_cache: dict[Scope, dict[nodes.Item, dict[FixtureArgKey, None]]],
|
||||
items_by_argkey: dict[Scope, dict[FixtureArgKey, OrderedDict[nodes.Item, None]]],
|
||||
) -> None:
|
||||
for scope in HIGH_SCOPES:
|
||||
scoped_items_by_argkey = items_by_argkey[scope]
|
||||
|
@ -237,20 +236,20 @@ def fix_cache_order(
|
|||
|
||||
|
||||
def reorder_items_atscope(
|
||||
items: Dict[nodes.Item, None],
|
||||
argkeys_cache: Dict[Scope, Dict[nodes.Item, Dict[FixtureArgKey, None]]],
|
||||
items_by_argkey: Dict[Scope, Dict[FixtureArgKey, OrderedDict[nodes.Item, None]]],
|
||||
items: dict[nodes.Item, None],
|
||||
argkeys_cache: dict[Scope, dict[nodes.Item, dict[FixtureArgKey, None]]],
|
||||
items_by_argkey: dict[Scope, dict[FixtureArgKey, OrderedDict[nodes.Item, None]]],
|
||||
scope: Scope,
|
||||
) -> Dict[nodes.Item, None]:
|
||||
) -> dict[nodes.Item, None]:
|
||||
if scope is Scope.Function or len(items) < 3:
|
||||
return items
|
||||
ignore: Set[Optional[FixtureArgKey]] = set()
|
||||
ignore: set[FixtureArgKey | None] = set()
|
||||
items_deque = deque(items)
|
||||
items_done: Dict[nodes.Item, None] = {}
|
||||
items_done: dict[nodes.Item, None] = {}
|
||||
scoped_items_by_argkey = items_by_argkey[scope]
|
||||
scoped_argkeys_cache = argkeys_cache[scope]
|
||||
while items_deque:
|
||||
no_argkey_group: Dict[nodes.Item, None] = {}
|
||||
no_argkey_group: dict[nodes.Item, None] = {}
|
||||
slicing_argkey = None
|
||||
while items_deque:
|
||||
item = items_deque.popleft()
|
||||
|
@ -1615,7 +1614,10 @@ class FixtureManager:
|
|||
name: str,
|
||||
func: _FixtureFunc[object],
|
||||
nodeid: str | None,
|
||||
scope: Scope | _ScopeName | Callable[[str, Config], _ScopeName] | None = "function",
|
||||
scope: Scope
|
||||
| _ScopeName
|
||||
| Callable[[str, Config], _ScopeName]
|
||||
| None = "function",
|
||||
params: Sequence[object] | None = None,
|
||||
ids: tuple[object | None, ...] | Callable[[Any], object | None] | None = None,
|
||||
autouse: bool = False,
|
||||
|
|
|
@ -486,7 +486,7 @@ class SetupState:
|
|||
# Node's finalizers.
|
||||
list[Callable[[], object]],
|
||||
# Node's exception and original traceback, if its setup raised.
|
||||
tuple[OutcomeException | Exception | None] | None,
|
||||
OutcomeException | Exception | None,
|
||||
],
|
||||
] = {}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from _pytest import nodes
|
||||
from _pytest.config import Config
|
||||
from _pytest.config.argparsing import Parser
|
||||
|
@ -8,6 +10,10 @@ from _pytest.reports import TestReport
|
|||
import pytest
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from _pytest.cacheprovider import Cache
|
||||
|
||||
|
||||
STEPWISE_CACHE_DIR = "cache/stepwise"
|
||||
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ class TestCaseFunction(Function):
|
|||
def startTest(self, testcase: unittest.TestCase) -> None:
|
||||
pass
|
||||
|
||||
def _addexcinfo(self, rawexcinfo: "_SysExcInfoType") -> None:
|
||||
def _addexcinfo(self, rawexcinfo: _SysExcInfoType) -> None:
|
||||
# Unwrap potential exception info (see twisted trial support below).
|
||||
rawexcinfo = getattr(rawexcinfo, "_rawexcinfo", rawexcinfo)
|
||||
try:
|
||||
|
@ -258,7 +258,7 @@ class TestCaseFunction(Function):
|
|||
self.__dict__.setdefault("_excinfo", []).append(excinfo)
|
||||
|
||||
def addError(
|
||||
self, testcase: unittest.TestCase, rawexcinfo: "_SysExcInfoType"
|
||||
self, testcase: unittest.TestCase, rawexcinfo: _SysExcInfoType
|
||||
) -> None:
|
||||
try:
|
||||
if isinstance(rawexcinfo[1], exit.Exception):
|
||||
|
@ -268,7 +268,7 @@ class TestCaseFunction(Function):
|
|||
self._addexcinfo(rawexcinfo)
|
||||
|
||||
def addFailure(
|
||||
self, testcase: unittest.TestCase, rawexcinfo: "_SysExcInfoType"
|
||||
self, testcase: unittest.TestCase, rawexcinfo: _SysExcInfoType
|
||||
) -> None:
|
||||
self._addexcinfo(rawexcinfo)
|
||||
|
||||
|
@ -281,7 +281,7 @@ class TestCaseFunction(Function):
|
|||
def addExpectedFailure(
|
||||
self,
|
||||
testcase: unittest.TestCase,
|
||||
rawexcinfo: "_SysExcInfoType",
|
||||
rawexcinfo: _SysExcInfoType,
|
||||
reason: str = "",
|
||||
) -> None:
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue