Init args in __init__ as well

This commit is contained in:
pytest bot 2023-01-21 07:51:29 -03:00
parent 72918bc050
commit 656fafc743
1 changed files with 4 additions and 3 deletions

View File

@ -999,6 +999,7 @@ class Config:
kwargs=dict(parser=self._parser, pluginmanager=self.pluginmanager) kwargs=dict(parser=self._parser, pluginmanager=self.pluginmanager)
) )
self.args_source = Config.ArgsSource.ARGS self.args_source = Config.ArgsSource.ARGS
self.args: List[str] = []
if TYPE_CHECKING: if TYPE_CHECKING:
from _pytest.cacheprovider import Cache from _pytest.cacheprovider import Cache
@ -1338,8 +1339,8 @@ class Config:
def parse(self, args: List[str], addopts: bool = True) -> None: def parse(self, args: List[str], addopts: bool = True) -> None:
# Parse given cmdline arguments into this config object. # Parse given cmdline arguments into this config object.
assert not hasattr( assert (
self, "args" self.args == []
), "can only parse cmdline args at most once per Config object" ), "can only parse cmdline args at most once per Config object"
self.hook.pytest_addhooks.call_historic( self.hook.pytest_addhooks.call_historic(
kwargs=dict(pluginmanager=self.pluginmanager) kwargs=dict(pluginmanager=self.pluginmanager)
@ -1369,7 +1370,7 @@ class Config:
self.args = args self.args = args
self.args_source = source self.args_source = source
except PrintHelp: except PrintHelp:
self.args = [] pass
def issue_config_time_warning(self, warning: Warning, stacklevel: int) -> None: def issue_config_time_warning(self, warning: Warning, stacklevel: int) -> None:
"""Issue and handle a warning during the "configure" stage. """Issue and handle a warning during the "configure" stage.