parent
2623ee2e0e
commit
109312ba86
|
@ -0,0 +1 @@
|
|||
``--version`` now writes version information to ``stdout`` rather than ``stderr``.
|
|
@ -127,7 +127,7 @@ def pytest_cmdline_parse():
|
|||
|
||||
def showversion(config: Config) -> None:
|
||||
if config.option.version > 1:
|
||||
sys.stderr.write(
|
||||
sys.stdout.write(
|
||||
"This is pytest version {}, imported from {}\n".format(
|
||||
pytest.__version__, pytest.__file__
|
||||
)
|
||||
|
@ -135,9 +135,9 @@ def showversion(config: Config) -> None:
|
|||
plugininfo = getpluginversioninfo(config)
|
||||
if plugininfo:
|
||||
for line in plugininfo:
|
||||
sys.stderr.write(line + "\n")
|
||||
sys.stdout.write(line + "\n")
|
||||
else:
|
||||
sys.stderr.write(f"pytest {pytest.__version__}\n")
|
||||
sys.stdout.write(f"pytest {pytest.__version__}\n")
|
||||
|
||||
|
||||
def pytest_cmdline_main(config: Config) -> Optional[Union[int, ExitCode]]:
|
||||
|
|
|
@ -1756,7 +1756,7 @@ def test_help_and_version_after_argument_error(pytester: Pytester) -> None:
|
|||
assert result.ret == ExitCode.USAGE_ERROR
|
||||
|
||||
result = pytester.runpytest("--version")
|
||||
result.stderr.fnmatch_lines([f"pytest {pytest.__version__}"])
|
||||
result.stdout.fnmatch_lines([f"pytest {pytest.__version__}"])
|
||||
assert result.ret == ExitCode.USAGE_ERROR
|
||||
|
||||
|
||||
|
|
|
@ -7,16 +7,16 @@ def test_version_verbose(pytester: Pytester, pytestconfig, monkeypatch) -> None:
|
|||
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD")
|
||||
result = pytester.runpytest("--version", "--version")
|
||||
assert result.ret == 0
|
||||
result.stderr.fnmatch_lines([f"*pytest*{pytest.__version__}*imported from*"])
|
||||
result.stdout.fnmatch_lines([f"*pytest*{pytest.__version__}*imported from*"])
|
||||
if pytestconfig.pluginmanager.list_plugin_distinfo():
|
||||
result.stderr.fnmatch_lines(["*setuptools registered plugins:", "*at*"])
|
||||
result.stdout.fnmatch_lines(["*setuptools registered plugins:", "*at*"])
|
||||
|
||||
|
||||
def test_version_less_verbose(pytester: Pytester, pytestconfig, monkeypatch) -> None:
|
||||
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD")
|
||||
result = pytester.runpytest("--version")
|
||||
assert result.ret == 0
|
||||
result.stderr.fnmatch_lines([f"pytest {pytest.__version__}"])
|
||||
result.stdout.fnmatch_lines([f"pytest {pytest.__version__}"])
|
||||
|
||||
|
||||
def test_versions():
|
||||
|
|
Loading…
Reference in New Issue