Skip to content

Commit 52268d2

Browse files
committed
config: remove unneeded parse in _consider_importhook
Can use the parse we did just before the call.
1 parent c8b03ba commit 52268d2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/_pytest/config/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,19 +1246,18 @@ def pytest_load_initial_conftests(self, early_config: Config) -> None:
12461246
),
12471247
)
12481248

1249-
def _consider_importhook(self, args: Sequence[str]) -> None:
1249+
def _consider_importhook(self) -> None:
12501250
"""Install the PEP 302 import hook if using assertion rewriting.
12511251
12521252
Needs to parse the --assert=<mode> option from the commandline
12531253
and find all the installed plugins to mark them for rewriting
12541254
by the importhook.
12551255
"""
1256-
ns = self._parser.parse_known_args(args)
1257-
mode = getattr(ns, "assertmode", "plain")
1256+
mode = getattr(self.known_args_namespace, "assertmode", "plain")
12581257

1259-
disable_autoload = getattr(ns, "disable_plugin_autoload", False) or bool(
1260-
os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD")
1261-
)
1258+
disable_autoload = getattr(
1259+
self.known_args_namespace, "disable_plugin_autoload", False
1260+
) or bool(os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD"))
12621261
if mode == "rewrite":
12631262
import _pytest.assertion
12641263

@@ -1406,7 +1405,7 @@ def _preparse(self, args: list[str], addopts: bool = True) -> None:
14061405
args, namespace=copy.copy(self.option)
14071406
)
14081407
self._checkversion()
1409-
self._consider_importhook(args)
1408+
self._consider_importhook()
14101409
self._configure_python_path()
14111410
self.pluginmanager.consider_preparse(args, exclude_only=False)
14121411
if (

0 commit comments

Comments
 (0)