Skip to content

Commit d208c1d

Browse files
authored
Merge pull request #12256 from bluetech/misc2
2 small cleanups
2 parents 93c2cdf + 80ca255 commit d208c1d

File tree

9 files changed

+11
-11
lines changed

9 files changed

+11
-11
lines changed

src/_pytest/_code/code.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from _pytest.pathlib import bestrelpath
5353

5454

55-
if sys.version_info[:2] < (3, 11):
55+
if sys.version_info < (3, 11):
5656
from exceptiongroup import BaseExceptionGroup
5757

5858
_TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto"]
@@ -703,7 +703,7 @@ def _stringify_exception(self, exc: BaseException) -> str:
703703
# Workaround for https://github.com/python/cpython/issues/98778 on
704704
# Python <= 3.9, and some 3.10 and 3.11 patch versions.
705705
HTTPError = getattr(sys.modules.get("urllib.error", None), "HTTPError", ())
706-
if sys.version_info[:2] <= (3, 11) and isinstance(exc, HTTPError):
706+
if sys.version_info < (3, 12) and isinstance(exc, HTTPError):
707707
notes = []
708708
else:
709709
raise

src/_pytest/config/argparsing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def parse_args( # type: ignore
448448
getattr(parsed, FILE_OR_DIR).extend(unrecognized)
449449
return parsed
450450

451-
if sys.version_info[:2] < (3, 9): # pragma: no cover
451+
if sys.version_info < (3, 9): # pragma: no cover
452452
# Backport of https://github.com/python/cpython/pull/14316 so we can
453453
# disable long --argument abbreviations without breaking short flags.
454454
def _parse_optional(

src/_pytest/fixtures.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
from _pytest.scope import Scope
7070

7171

72-
if sys.version_info[:2] < (3, 11):
72+
if sys.version_info < (3, 11):
7373
from exceptiongroup import BaseExceptionGroup
7474

7575

src/_pytest/nodes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ def location(self) -> Tuple[str, Optional[int], str]:
765765
and lineno is a 0-based line number.
766766
"""
767767
location = self.reportinfo()
768-
path = absolutepath(os.fspath(location[0]))
768+
path = absolutepath(location[0])
769769
relfspath = self.session._node_location_to_relpath(path)
770770
assert type(location[2]) is str
771771
return (relfspath, location[1], location[2])

src/_pytest/pathlib.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -924,13 +924,13 @@ def visit(
924924
yield from visit(entry.path, recurse)
925925

926926

927-
def absolutepath(path: Union[Path, str]) -> Path:
927+
def absolutepath(path: "Union[str, os.PathLike[str]]") -> Path:
928928
"""Convert a path to an absolute path using os.path.abspath.
929929
930930
Prefer this over Path.resolve() (see #6523).
931931
Prefer this over Path.absolute() (not public, doesn't normalize).
932932
"""
933-
return Path(os.path.abspath(str(path)))
933+
return Path(os.path.abspath(path))
934934

935935

936936
def commonpath(path1: Path, path2: Path) -> Optional[Path]:

src/_pytest/runner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from _pytest.outcomes import TEST_OUTCOME
4040

4141

42-
if sys.version_info[:2] < (3, 11):
42+
if sys.version_info < (3, 11):
4343
from exceptiongroup import BaseExceptionGroup
4444

4545
if TYPE_CHECKING:

testing/code/test_excinfo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
if TYPE_CHECKING:
2929
from _pytest._code.code import _TracebackStyle
3030

31-
if sys.version_info[:2] < (3, 11):
31+
if sys.version_info < (3, 11):
3232
from exceptiongroup import ExceptionGroup
3333

3434

testing/test_runner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import pytest
2424

2525

26-
if sys.version_info[:2] < (3, 11):
26+
if sys.version_info < (3, 11):
2727
from exceptiongroup import ExceptionGroup
2828

2929

testing/test_skipping.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ def test_func():
11461146
if pypy_version_info is not None and pypy_version_info < (6,):
11471147
markline = markline[1:]
11481148

1149-
if sys.version_info[:2] >= (3, 10):
1149+
if sys.version_info >= (3, 10):
11501150
expected = [
11511151
"*ERROR*test_nameerror*",
11521152
"*asd*",

0 commit comments

Comments
 (0)