Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix option error #10608

Merged
merged 6 commits into from Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -377,6 +377,7 @@ Xixi Zhao
Xuan Luong
Xuecong Liao
Yoav Caspi
Yuliang Shao
Yusuke Kadowaki
Yuval Shimon
Zac Hatfield-Dodds
Expand Down
1 change: 1 addition & 0 deletions changelog/10592.bugfix.rst
@@ -0,0 +1 @@
Fixed crash if `--cache-show` and `--help` are passed at the same time.
3 changes: 1 addition & 2 deletions src/_pytest/cacheprovider.py
Expand Up @@ -32,7 +32,6 @@
from _pytest.python import Package
from _pytest.reports import TestReport


README_CONTENT = """\
# pytest cache directory #

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions testing/test_cacheprovider.py
Expand Up @@ -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