Skip to content

Commit

Permalink
Init config args and args_source
Browse files Browse the repository at this point in the history
  • Loading branch information
q0w committed Jan 19, 2023
1 parent 00c8bea commit 53a8a94
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/_pytest/config/__init__.py
Expand Up @@ -998,6 +998,7 @@ def __init__(
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
Expand Down Expand Up @@ -1368,7 +1369,7 @@ def parse(self, args: List[str], addopts: bool = True) -> None:
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.
Expand Down
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 if hasattr(self.config, "args") else ()
args = self.config.args

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

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))

Expand Down

0 comments on commit 53a8a94

Please sign in to comment.