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

Check if config args and args_source exist #10664

Merged
merged 4 commits into from Jan 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -290,6 +290,7 @@ Prashant Sharma
Pulkit Goyal
Punyashloka Biswal
Quentin Pradet
q0w
Ralf Schmitt
Ralph Giles
Ram Rachum
Expand Down
1 change: 1 addition & 0 deletions changelog/10626.bugfix.rst
@@ -0,0 +1 @@
Check if ``Config.args`` and ``Config.args_source`` exist.
q0w marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion src/_pytest/main.py
Expand Up @@ -619,7 +619,7 @@ def perform_collect( # noqa: F811
and ``session.items`` is empty.
"""
if args is None:
args = self.config.args
args = self.config.args if hasattr(self.config, "args") else ()

self.trace("perform_collect", self, args)
self.trace.root.indent += 1
Expand Down
6 changes: 4 additions & 2 deletions src/_pytest/terminal.py
Expand Up @@ -737,8 +737,10 @@ def pytest_report_header(self, config: Config) -> List[str]:

if config.inipath:
line += ", configfile: " + bestrelpath(config.rootpath, config.inipath)

if config.args_source == Config.ArgsSource.TESTPATHS:
if (
hasattr(config, "args_source")
and config.args_source == Config.ArgsSource.TESTPATHS
):
testpaths: List[str] = config.getini("testpaths")
line += ", testpaths: {}".format(", ".join(testpaths))

Expand Down
4 changes: 4 additions & 0 deletions testing/python/fixtures.py
Expand Up @@ -3338,6 +3338,10 @@ def test_funcarg_compat(self, pytester: Pytester) -> None:
config = pytester.parseconfigure("--funcargs")
assert config.option.showfixtures

def test_show_help(self, pytester: Pytester) -> None:
result = pytester.runpytest("--fixtures", "--help")
assert not result.ret

def test_show_fixtures(self, pytester: Pytester) -> None:
result = pytester.runpytest("--fixtures")
result.stdout.fnmatch_lines(
Expand Down