Fix crash if `--cache-show` and `--help` are passed at the same time

Closes #10592
This commit is contained in:
Ramsey 2023-01-19 20:44:57 +08:00 committed by GitHub
parent 096b942ec4
commit 4d4ed42c34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 2 deletions

View File

@ -378,6 +378,7 @@ Xixi Zhao
Xuan Luong
Xuecong Liao
Yoav Caspi
Yuliang Shao
Yusuke Kadowaki
Yuval Shimon
Zac Hatfield-Dodds

View File

@ -0,0 +1 @@
Fixed crash if `--cache-show` and `--help` are passed at the same time.

View File

@ -32,7 +32,6 @@ from _pytest.python import Module
from _pytest.python import Package
from _pytest.reports import TestReport
README_CONTENT = """\
# pytest cache directory #
@ -492,7 +491,7 @@ def pytest_addoption(parser: Parser) -> None:
def pytest_cmdline_main(config: Config) -> Optional[Union[int, ExitCode]]:
if config.option.cacheshow:
if config.option.cacheshow and not config.option.help:
from _pytest.main import wrap_session
return wrap_session(config, cacheshow)

View File

@ -1249,3 +1249,8 @@ def test_cachedir_tag(pytester: Pytester) -> None:
cache.set("foo", "bar")
cachedir_tag_path = cache._cachedir.joinpath("CACHEDIR.TAG")
assert cachedir_tag_path.read_bytes() == CACHEDIR_TAG_CONTENT
def test_clioption_with_cacheshow_and_help(pytester: Pytester) -> None:
result = pytester.runpytest("--cache-show", "--help")
assert result.ret == 0