Remove py version printing, traceback filtering, freezing

Not so important anymore, and makes it easier to remove the py
dependency.
This commit is contained in:
Ran Benita 2021-10-16 01:57:12 +03:00
parent bc2f20722c
commit a3b69d9d83
8 changed files with 13 additions and 49 deletions

View File

@ -1240,7 +1240,6 @@ _PLUGGY_DIR = Path(pluggy.__file__.rstrip("oc"))
if _PLUGGY_DIR.name == "__init__.py":
_PLUGGY_DIR = _PLUGGY_DIR.parent
_PYTEST_DIR = Path(_pytest.__file__).parent
_PY_DIR = Path(__import__("py").__file__).parent
def filter_traceback(entry: TracebackEntry) -> bool:
@ -1268,7 +1267,5 @@ def filter_traceback(entry: TracebackEntry) -> bool:
return False
if _PYTEST_DIR in parents:
return False
if _PY_DIR in parents:
return False
return True

View File

@ -9,11 +9,9 @@ from typing import Union
def freeze_includes() -> List[str]:
"""Return a list of module names used by pytest that should be
included by cx_freeze."""
import py
import _pytest
result = list(_iter_all_modules(py))
result += list(_iter_all_modules(_pytest))
result = list(_iter_all_modules(_pytest))
return result

View File

@ -6,8 +6,6 @@ from typing import List
from typing import Optional
from typing import Union
import py
import pytest
from _pytest.config import Config
from _pytest.config import ExitCode
@ -108,11 +106,10 @@ def pytest_cmdline_parse():
path = config.option.debug
debugfile = open(path, "w")
debugfile.write(
"versions pytest-%s, py-%s, "
"versions pytest-%s, "
"python-%s\ncwd=%s\nargs=%s\n\n"
% (
pytest.__version__,
py.__version__,
".".join(map(str, sys.version_info)),
os.getcwd(),
config.invocation_params.args,
@ -249,7 +246,7 @@ def getpluginversioninfo(config: Config) -> List[str]:
def pytest_report_header(config: Config) -> List[str]:
lines = []
if config.option.debug or config.option.traceconfig:
lines.append(f"using: pytest-{pytest.__version__} pylib-{py.__version__}")
lines.append(f"using: pytest-{pytest.__version__}")
verinfo = getpluginversioninfo(config)
if verinfo:

View File

@ -29,7 +29,6 @@ from typing import Union
import attr
import pluggy
import py
import _pytest._version
from _pytest import nodes
@ -704,8 +703,8 @@ class TerminalReporter:
if pypy_version_info:
verinfo = ".".join(map(str, pypy_version_info[:3]))
msg += f"[pypy-{verinfo}-{pypy_version_info[3]}]"
msg += ", pytest-{}, py-{}, pluggy-{}".format(
_pytest._version.version, py.__version__, pluggy.__version__
msg += ", pytest-{}, pluggy-{}".format(
_pytest._version.version, pluggy.__version__
)
if (
self.verbosity > 0

View File

@ -3,7 +3,6 @@ import sys
import types
import attr
import py
import pytest
from _pytest.compat import importlib_metadata
@ -515,28 +514,10 @@ class TestInvocationVariants:
assert result.ret == 0
def test_pydoc(self, pytester: Pytester) -> None:
for name in ("py.test", "pytest"):
result = pytester.runpython_c(f"import {name};help({name})")
assert result.ret == 0
s = result.stdout.str()
assert "MarkGenerator" in s
def test_import_star_py_dot_test(self, pytester: Pytester) -> None:
p = pytester.makepyfile(
"""
from py.test import *
#collect
#cmdline
#Item
# assert collect.Item is Item
# assert collect.Collector is Collector
main
skip
xfail
"""
)
result = pytester.runpython(p)
result = pytester.runpython_c("import pytest;help(pytest)")
assert result.ret == 0
s = result.stdout.str()
assert "MarkGenerator" in s
def test_import_star_pytest(self, pytester: Pytester) -> None:
p = pytester.makepyfile(
@ -585,10 +566,6 @@ class TestInvocationVariants:
assert res.ret == 0
res.stdout.fnmatch_lines(["*1 passed*"])
def test_equivalence_pytest_pydottest(self) -> None:
# Type ignored because `py.test` is not and will not be typed.
assert pytest.main == py.test.cmdline.main # type: ignore[attr-defined]
def test_invoke_with_invalid_type(self) -> None:
with pytest.raises(
TypeError, match="expected to be a list of strings, got: '-h'"

View File

@ -105,7 +105,7 @@ def test_hookvalidation_optional(pytester: Pytester) -> None:
def test_traceconfig(pytester: Pytester) -> None:
result = pytester.runpytest("--traceconfig")
result.stdout.fnmatch_lines(["*using*pytest*py*", "*active plugins*"])
result.stdout.fnmatch_lines(["*using*pytest*", "*active plugins*"])
def test_debug(pytester: Pytester) -> None:

View File

@ -15,9 +15,8 @@ from _pytest.pytester import Pytester
class TestMark:
@pytest.mark.parametrize("attr", ["mark", "param"])
@pytest.mark.parametrize("modulename", ["py.test", "pytest"])
def test_pytest_exists_in_namespace_all(self, attr: str, modulename: str) -> None:
module = sys.modules[modulename]
def test_pytest_exists_in_namespace_all(self, attr: str) -> None:
module = sys.modules["pytest"]
assert attr in module.__all__ # type: ignore
def test_pytest_mark_notcallable(self) -> None:

View File

@ -12,7 +12,6 @@ from typing import List
from typing import Tuple
import pluggy
import py
import _pytest.config
import _pytest.terminal
@ -800,12 +799,11 @@ class TestTerminalFunctional:
result.stdout.fnmatch_lines(
[
"*===== test session starts ====*",
"platform %s -- Python %s*pytest-%s*py-%s*pluggy-%s"
"platform %s -- Python %s*pytest-%s**pluggy-%s"
% (
sys.platform,
verinfo,
pytest.__version__,
py.__version__,
pluggy.__version__,
),
"*test_header_trailer_info.py .*",
@ -828,12 +826,11 @@ class TestTerminalFunctional:
result = pytester.runpytest("--no-header")
verinfo = ".".join(map(str, sys.version_info[:3]))
result.stdout.no_fnmatch_line(
"platform %s -- Python %s*pytest-%s*py-%s*pluggy-%s"
"platform %s -- Python %s*pytest-%s**pluggy-%s"
% (
sys.platform,
verinfo,
pytest.__version__,
py.__version__,
pluggy.__version__,
)
)