Skip to content

Commit 0696d3e

Browse files
authored
Merge pull request #9207 from bluetech/rm-py-pre
Remove some `py` uses
2 parents 5fc7b21 + a3b69d9 commit 0696d3e

File tree

10 files changed

+16
-53
lines changed

10 files changed

+16
-53
lines changed

src/_pytest/_code/code.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,6 @@ def getfslineno(obj: object) -> Tuple[Union[str, Path], int]:
12401240
if _PLUGGY_DIR.name == "__init__.py":
12411241
_PLUGGY_DIR = _PLUGGY_DIR.parent
12421242
_PYTEST_DIR = Path(_pytest.__file__).parent
1243-
_PY_DIR = Path(__import__("py").__file__).parent
12441243

12451244

12461245
def filter_traceback(entry: TracebackEntry) -> bool:
@@ -1268,7 +1267,5 @@ def filter_traceback(entry: TracebackEntry) -> bool:
12681267
return False
12691268
if _PYTEST_DIR in parents:
12701269
return False
1271-
if _PY_DIR in parents:
1272-
return False
12731270

12741271
return True

src/_pytest/freeze_support.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
def freeze_includes() -> List[str]:
1010
"""Return a list of module names used by pytest that should be
1111
included by cx_freeze."""
12-
import py
1312
import _pytest
1413

15-
result = list(_iter_all_modules(py))
16-
result += list(_iter_all_modules(_pytest))
14+
result = list(_iter_all_modules(_pytest))
1715
return result
1816

1917

src/_pytest/helpconfig.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from typing import Optional
77
from typing import Union
88

9-
import py
10-
119
import pytest
1210
from _pytest.config import Config
1311
from _pytest.config import ExitCode
@@ -108,11 +106,10 @@ def pytest_cmdline_parse():
108106
path = config.option.debug
109107
debugfile = open(path, "w")
110108
debugfile.write(
111-
"versions pytest-%s, py-%s, "
109+
"versions pytest-%s, "
112110
"python-%s\ncwd=%s\nargs=%s\n\n"
113111
% (
114112
pytest.__version__,
115-
py.__version__,
116113
".".join(map(str, sys.version_info)),
117114
os.getcwd(),
118115
config.invocation_params.args,
@@ -249,7 +246,7 @@ def getpluginversioninfo(config: Config) -> List[str]:
249246
def pytest_report_header(config: Config) -> List[str]:
250247
lines = []
251248
if config.option.debug or config.option.traceconfig:
252-
lines.append(f"using: pytest-{pytest.__version__} pylib-{py.__version__}")
249+
lines.append(f"using: pytest-{pytest.__version__}")
253250

254251
verinfo = getpluginversioninfo(config)
255252
if verinfo:

src/_pytest/terminal.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
import attr
3131
import pluggy
32-
import py
3332

3433
import _pytest._version
3534
from _pytest import nodes
@@ -704,8 +703,8 @@ def pytest_sessionstart(self, session: "Session") -> None:
704703
if pypy_version_info:
705704
verinfo = ".".join(map(str, pypy_version_info[:3]))
706705
msg += f"[pypy-{verinfo}-{pypy_version_info[3]}]"
707-
msg += ", pytest-{}, py-{}, pluggy-{}".format(
708-
_pytest._version.version, py.__version__, pluggy.__version__
706+
msg += ", pytest-{}, pluggy-{}".format(
707+
_pytest._version.version, pluggy.__version__
709708
)
710709
if (
711710
self.verbosity > 0

testing/acceptance_test.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import types
44

55
import attr
6-
import py
76

87
import pytest
98
from _pytest.compat import importlib_metadata
@@ -515,28 +514,10 @@ def test_earlyinit(self, pytester: Pytester) -> None:
515514
assert result.ret == 0
516515

517516
def test_pydoc(self, pytester: Pytester) -> None:
518-
for name in ("py.test", "pytest"):
519-
result = pytester.runpython_c(f"import {name};help({name})")
520-
assert result.ret == 0
521-
s = result.stdout.str()
522-
assert "MarkGenerator" in s
523-
524-
def test_import_star_py_dot_test(self, pytester: Pytester) -> None:
525-
p = pytester.makepyfile(
526-
"""
527-
from py.test import *
528-
#collect
529-
#cmdline
530-
#Item
531-
# assert collect.Item is Item
532-
# assert collect.Collector is Collector
533-
main
534-
skip
535-
xfail
536-
"""
537-
)
538-
result = pytester.runpython(p)
517+
result = pytester.runpython_c("import pytest;help(pytest)")
539518
assert result.ret == 0
519+
s = result.stdout.str()
520+
assert "MarkGenerator" in s
540521

541522
def test_import_star_pytest(self, pytester: Pytester) -> None:
542523
p = pytester.makepyfile(
@@ -585,10 +566,6 @@ def test_python_pytest_package(self, pytester: Pytester) -> None:
585566
assert res.ret == 0
586567
res.stdout.fnmatch_lines(["*1 passed*"])
587568

588-
def test_equivalence_pytest_pydottest(self) -> None:
589-
# Type ignored because `py.test` is not and will not be typed.
590-
assert pytest.main == py.test.cmdline.main # type: ignore[attr-defined]
591-
592569
def test_invoke_with_invalid_type(self) -> None:
593570
with pytest.raises(
594571
TypeError, match="expected to be a list of strings, got: '-h'"

testing/test_capture.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,8 +1379,7 @@ def test_capturing_and_logging_fundamentals(pytester: Pytester, method: str) ->
13791379
# here we check a fundamental feature
13801380
p = pytester.makepyfile(
13811381
"""
1382-
import sys, os
1383-
import py, logging
1382+
import sys, os, logging
13841383
from _pytest import capture
13851384
cap = capture.MultiCapture(
13861385
in_=None,

testing/test_helpconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def pytest_hello(xyz):
105105

106106
def test_traceconfig(pytester: Pytester) -> None:
107107
result = pytester.runpytest("--traceconfig")
108-
result.stdout.fnmatch_lines(["*using*pytest*py*", "*active plugins*"])
108+
result.stdout.fnmatch_lines(["*using*pytest*", "*active plugins*"])
109109

110110

111111
def test_debug(pytester: Pytester) -> None:

testing/test_mark.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515

1616
class TestMark:
1717
@pytest.mark.parametrize("attr", ["mark", "param"])
18-
@pytest.mark.parametrize("modulename", ["py.test", "pytest"])
19-
def test_pytest_exists_in_namespace_all(self, attr: str, modulename: str) -> None:
20-
module = sys.modules[modulename]
18+
def test_pytest_exists_in_namespace_all(self, attr: str) -> None:
19+
module = sys.modules["pytest"]
2120
assert attr in module.__all__ # type: ignore
2221

2322
def test_pytest_mark_notcallable(self) -> None:

testing/test_pathlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def setuptestfs(self, path: Path) -> None:
121121
module_c.write_text(
122122
dedent(
123123
"""
124-
import py;
124+
import pluggy;
125125
import otherdir.a
126126
value = otherdir.a.result
127127
"""
@@ -131,7 +131,7 @@ def setuptestfs(self, path: Path) -> None:
131131
module_d.write_text(
132132
dedent(
133133
"""
134-
import py;
134+
import pluggy;
135135
from otherdir import a
136136
value2 = a.result
137137
"""

testing/test_terminal.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from typing import Tuple
1313

1414
import pluggy
15-
import py
1615

1716
import _pytest.config
1817
import _pytest.terminal
@@ -800,12 +799,11 @@ def test_passes():
800799
result.stdout.fnmatch_lines(
801800
[
802801
"*===== test session starts ====*",
803-
"platform %s -- Python %s*pytest-%s*py-%s*pluggy-%s"
802+
"platform %s -- Python %s*pytest-%s**pluggy-%s"
804803
% (
805804
sys.platform,
806805
verinfo,
807806
pytest.__version__,
808-
py.__version__,
809807
pluggy.__version__,
810808
),
811809
"*test_header_trailer_info.py .*",
@@ -828,12 +826,11 @@ def test_passes():
828826
result = pytester.runpytest("--no-header")
829827
verinfo = ".".join(map(str, sys.version_info[:3]))
830828
result.stdout.no_fnmatch_line(
831-
"platform %s -- Python %s*pytest-%s*py-%s*pluggy-%s"
829+
"platform %s -- Python %s*pytest-%s**pluggy-%s"
832830
% (
833831
sys.platform,
834832
verinfo,
835833
pytest.__version__,
836-
py.__version__,
837834
pluggy.__version__,
838835
)
839836
)

0 commit comments

Comments
 (0)