Check if config args and args_source exist

This commit is contained in:
q0w 2023-01-14 22:28:33 +03:00
parent 03b19945fb
commit ee57a2ad45
5 changed files with 11 additions and 3 deletions

View File

@ -290,6 +290,7 @@ Prashant Sharma
Pulkit Goyal
Punyashloka Biswal
Quentin Pradet
q0w
Ralf Schmitt
Ralph Giles
Ram Rachum

View File

@ -0,0 +1 @@
Check if ``Config.args`` and ``Config.args_source`` exist.

View File

@ -619,7 +619,7 @@ class Session(nodes.FSCollector):
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

View File

@ -737,8 +737,10 @@ class TerminalReporter:
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))

View File

@ -3338,6 +3338,10 @@ class TestShowFixtures:
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(