Initialize args and args_source during Config.__init__
Closes #10626 Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
This commit is contained in:
parent
6a714d7b70
commit
bd7919e03d
1
AUTHORS
1
AUTHORS
|
@ -290,6 +290,7 @@ Prashant Sharma
|
||||||
Pulkit Goyal
|
Pulkit Goyal
|
||||||
Punyashloka Biswal
|
Punyashloka Biswal
|
||||||
Quentin Pradet
|
Quentin Pradet
|
||||||
|
q0w
|
||||||
Ralf Schmitt
|
Ralf Schmitt
|
||||||
Ralph Giles
|
Ralph Giles
|
||||||
Ram Rachum
|
Ram Rachum
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix crash if ``--fixtures`` and ``--help`` are passed at the same time.
|
|
@ -1005,6 +1005,8 @@ class Config:
|
||||||
self.hook.pytest_addoption.call_historic(
|
self.hook.pytest_addoption.call_historic(
|
||||||
kwargs=dict(parser=self._parser, pluginmanager=self.pluginmanager)
|
kwargs=dict(parser=self._parser, pluginmanager=self.pluginmanager)
|
||||||
)
|
)
|
||||||
|
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
|
||||||
|
@ -1344,8 +1346,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)
|
||||||
|
|
|
@ -3338,6 +3338,10 @@ class TestShowFixtures:
|
||||||
config = pytester.parseconfigure("--funcargs")
|
config = pytester.parseconfigure("--funcargs")
|
||||||
assert config.option.showfixtures
|
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:
|
def test_show_fixtures(self, pytester: Pytester) -> None:
|
||||||
result = pytester.runpytest("--fixtures")
|
result = pytester.runpytest("--fixtures")
|
||||||
result.stdout.fnmatch_lines(
|
result.stdout.fnmatch_lines(
|
||||||
|
|
Loading…
Reference in New Issue