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:
parent
bc2f20722c
commit
a3b69d9d83
|
@ -1240,7 +1240,6 @@ _PLUGGY_DIR = Path(pluggy.__file__.rstrip("oc"))
|
||||||
if _PLUGGY_DIR.name == "__init__.py":
|
if _PLUGGY_DIR.name == "__init__.py":
|
||||||
_PLUGGY_DIR = _PLUGGY_DIR.parent
|
_PLUGGY_DIR = _PLUGGY_DIR.parent
|
||||||
_PYTEST_DIR = Path(_pytest.__file__).parent
|
_PYTEST_DIR = Path(_pytest.__file__).parent
|
||||||
_PY_DIR = Path(__import__("py").__file__).parent
|
|
||||||
|
|
||||||
|
|
||||||
def filter_traceback(entry: TracebackEntry) -> bool:
|
def filter_traceback(entry: TracebackEntry) -> bool:
|
||||||
|
@ -1268,7 +1267,5 @@ def filter_traceback(entry: TracebackEntry) -> bool:
|
||||||
return False
|
return False
|
||||||
if _PYTEST_DIR in parents:
|
if _PYTEST_DIR in parents:
|
||||||
return False
|
return False
|
||||||
if _PY_DIR in parents:
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -9,11 +9,9 @@ from typing import Union
|
||||||
def freeze_includes() -> List[str]:
|
def freeze_includes() -> List[str]:
|
||||||
"""Return a list of module names used by pytest that should be
|
"""Return a list of module names used by pytest that should be
|
||||||
included by cx_freeze."""
|
included by cx_freeze."""
|
||||||
import py
|
|
||||||
import _pytest
|
import _pytest
|
||||||
|
|
||||||
result = list(_iter_all_modules(py))
|
result = list(_iter_all_modules(_pytest))
|
||||||
result += list(_iter_all_modules(_pytest))
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@ from typing import List
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
import py
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest.config import Config
|
from _pytest.config import Config
|
||||||
from _pytest.config import ExitCode
|
from _pytest.config import ExitCode
|
||||||
|
@ -108,11 +106,10 @@ def pytest_cmdline_parse():
|
||||||
path = config.option.debug
|
path = config.option.debug
|
||||||
debugfile = open(path, "w")
|
debugfile = open(path, "w")
|
||||||
debugfile.write(
|
debugfile.write(
|
||||||
"versions pytest-%s, py-%s, "
|
"versions pytest-%s, "
|
||||||
"python-%s\ncwd=%s\nargs=%s\n\n"
|
"python-%s\ncwd=%s\nargs=%s\n\n"
|
||||||
% (
|
% (
|
||||||
pytest.__version__,
|
pytest.__version__,
|
||||||
py.__version__,
|
|
||||||
".".join(map(str, sys.version_info)),
|
".".join(map(str, sys.version_info)),
|
||||||
os.getcwd(),
|
os.getcwd(),
|
||||||
config.invocation_params.args,
|
config.invocation_params.args,
|
||||||
|
@ -249,7 +246,7 @@ def getpluginversioninfo(config: Config) -> List[str]:
|
||||||
def pytest_report_header(config: Config) -> List[str]:
|
def pytest_report_header(config: Config) -> List[str]:
|
||||||
lines = []
|
lines = []
|
||||||
if config.option.debug or config.option.traceconfig:
|
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)
|
verinfo = getpluginversioninfo(config)
|
||||||
if verinfo:
|
if verinfo:
|
||||||
|
|
|
@ -29,7 +29,6 @@ from typing import Union
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
import pluggy
|
import pluggy
|
||||||
import py
|
|
||||||
|
|
||||||
import _pytest._version
|
import _pytest._version
|
||||||
from _pytest import nodes
|
from _pytest import nodes
|
||||||
|
@ -704,8 +703,8 @@ class TerminalReporter:
|
||||||
if pypy_version_info:
|
if pypy_version_info:
|
||||||
verinfo = ".".join(map(str, pypy_version_info[:3]))
|
verinfo = ".".join(map(str, pypy_version_info[:3]))
|
||||||
msg += f"[pypy-{verinfo}-{pypy_version_info[3]}]"
|
msg += f"[pypy-{verinfo}-{pypy_version_info[3]}]"
|
||||||
msg += ", pytest-{}, py-{}, pluggy-{}".format(
|
msg += ", pytest-{}, pluggy-{}".format(
|
||||||
_pytest._version.version, py.__version__, pluggy.__version__
|
_pytest._version.version, pluggy.__version__
|
||||||
)
|
)
|
||||||
if (
|
if (
|
||||||
self.verbosity > 0
|
self.verbosity > 0
|
||||||
|
|
|
@ -3,7 +3,6 @@ import sys
|
||||||
import types
|
import types
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
import py
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest.compat import importlib_metadata
|
from _pytest.compat import importlib_metadata
|
||||||
|
@ -515,29 +514,11 @@ class TestInvocationVariants:
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
|
|
||||||
def test_pydoc(self, pytester: Pytester) -> None:
|
def test_pydoc(self, pytester: Pytester) -> None:
|
||||||
for name in ("py.test", "pytest"):
|
result = pytester.runpython_c("import pytest;help(pytest)")
|
||||||
result = pytester.runpython_c(f"import {name};help({name})")
|
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
s = result.stdout.str()
|
s = result.stdout.str()
|
||||||
assert "MarkGenerator" in s
|
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)
|
|
||||||
assert result.ret == 0
|
|
||||||
|
|
||||||
def test_import_star_pytest(self, pytester: Pytester) -> None:
|
def test_import_star_pytest(self, pytester: Pytester) -> None:
|
||||||
p = pytester.makepyfile(
|
p = pytester.makepyfile(
|
||||||
"""
|
"""
|
||||||
|
@ -585,10 +566,6 @@ class TestInvocationVariants:
|
||||||
assert res.ret == 0
|
assert res.ret == 0
|
||||||
res.stdout.fnmatch_lines(["*1 passed*"])
|
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:
|
def test_invoke_with_invalid_type(self) -> None:
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
TypeError, match="expected to be a list of strings, got: '-h'"
|
TypeError, match="expected to be a list of strings, got: '-h'"
|
||||||
|
|
|
@ -105,7 +105,7 @@ def test_hookvalidation_optional(pytester: Pytester) -> None:
|
||||||
|
|
||||||
def test_traceconfig(pytester: Pytester) -> None:
|
def test_traceconfig(pytester: Pytester) -> None:
|
||||||
result = pytester.runpytest("--traceconfig")
|
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:
|
def test_debug(pytester: Pytester) -> None:
|
||||||
|
|
|
@ -15,9 +15,8 @@ from _pytest.pytester import Pytester
|
||||||
|
|
||||||
class TestMark:
|
class TestMark:
|
||||||
@pytest.mark.parametrize("attr", ["mark", "param"])
|
@pytest.mark.parametrize("attr", ["mark", "param"])
|
||||||
@pytest.mark.parametrize("modulename", ["py.test", "pytest"])
|
def test_pytest_exists_in_namespace_all(self, attr: str) -> None:
|
||||||
def test_pytest_exists_in_namespace_all(self, attr: str, modulename: str) -> None:
|
module = sys.modules["pytest"]
|
||||||
module = sys.modules[modulename]
|
|
||||||
assert attr in module.__all__ # type: ignore
|
assert attr in module.__all__ # type: ignore
|
||||||
|
|
||||||
def test_pytest_mark_notcallable(self) -> None:
|
def test_pytest_mark_notcallable(self) -> None:
|
||||||
|
|
|
@ -12,7 +12,6 @@ from typing import List
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
import pluggy
|
import pluggy
|
||||||
import py
|
|
||||||
|
|
||||||
import _pytest.config
|
import _pytest.config
|
||||||
import _pytest.terminal
|
import _pytest.terminal
|
||||||
|
@ -800,12 +799,11 @@ class TestTerminalFunctional:
|
||||||
result.stdout.fnmatch_lines(
|
result.stdout.fnmatch_lines(
|
||||||
[
|
[
|
||||||
"*===== test session starts ====*",
|
"*===== test session starts ====*",
|
||||||
"platform %s -- Python %s*pytest-%s*py-%s*pluggy-%s"
|
"platform %s -- Python %s*pytest-%s**pluggy-%s"
|
||||||
% (
|
% (
|
||||||
sys.platform,
|
sys.platform,
|
||||||
verinfo,
|
verinfo,
|
||||||
pytest.__version__,
|
pytest.__version__,
|
||||||
py.__version__,
|
|
||||||
pluggy.__version__,
|
pluggy.__version__,
|
||||||
),
|
),
|
||||||
"*test_header_trailer_info.py .*",
|
"*test_header_trailer_info.py .*",
|
||||||
|
@ -828,12 +826,11 @@ class TestTerminalFunctional:
|
||||||
result = pytester.runpytest("--no-header")
|
result = pytester.runpytest("--no-header")
|
||||||
verinfo = ".".join(map(str, sys.version_info[:3]))
|
verinfo = ".".join(map(str, sys.version_info[:3]))
|
||||||
result.stdout.no_fnmatch_line(
|
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,
|
sys.platform,
|
||||||
verinfo,
|
verinfo,
|
||||||
pytest.__version__,
|
pytest.__version__,
|
||||||
py.__version__,
|
|
||||||
pluggy.__version__,
|
pluggy.__version__,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue