Init config args and args_source

This commit is contained in:
q0w 2023-01-20 01:50:22 +03:00
parent 00c8beab45
commit 72918bc050
3 changed files with 5 additions and 6 deletions

View File

@ -998,6 +998,7 @@ class Config:
self.hook.pytest_addoption.call_historic(
kwargs=dict(parser=self._parser, pluginmanager=self.pluginmanager)
)
self.args_source = Config.ArgsSource.ARGS
if TYPE_CHECKING:
from _pytest.cacheprovider import Cache
@ -1368,7 +1369,7 @@ class Config:
self.args = args
self.args_source = source
except PrintHelp:
pass
self.args = []
def issue_config_time_warning(self, warning: Warning, stacklevel: int) -> None:
"""Issue and handle a warning during the "configure" stage.

View File

@ -619,7 +619,7 @@ class Session(nodes.FSCollector):
and ``session.items`` is empty.
"""
if args is None:
args = self.config.args if hasattr(self.config, "args") else ()
args = self.config.args
self.trace("perform_collect", self, args)
self.trace.root.indent += 1

View File

@ -737,10 +737,8 @@ class TerminalReporter:
if config.inipath:
line += ", configfile: " + bestrelpath(config.rootpath, config.inipath)
if (
hasattr(config, "args_source")
and config.args_source == Config.ArgsSource.TESTPATHS
):
if config.args_source == Config.ArgsSource.TESTPATHS:
testpaths: List[str] = config.getini("testpaths")
line += ", testpaths: {}".format(", ".join(testpaths))