Skip to content

Commit 9f4bb0f

Browse files
committed
config: inline _initini
It doesn't help understanding much and doesn't deal with only ini (config). So inline it into `_preparse`.
1 parent 8e5a0b2 commit 9f4bb0f

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

src/_pytest/config/__init__.py

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

1249-
def _initini(self, args: Sequence[str]) -> None:
1250-
ns, unknown_args = self._parser.parse_known_and_unknown_args(
1251-
args, namespace=copy.copy(self.option)
1252-
)
1253-
rootpath, inipath, inicfg, ignored_config_files = determine_setup(
1254-
inifile=ns.inifilename,
1255-
override_ini=ns.override_ini,
1256-
args=ns.file_or_dir + unknown_args,
1257-
rootdir_cmd_arg=ns.rootdir or None,
1258-
invocation_dir=self.invocation_params.dir,
1259-
)
1260-
self._rootpath = rootpath
1261-
self._inipath = inipath
1262-
self._ignored_config_files = ignored_config_files
1263-
self.inicfg = inicfg
1264-
self._parser.extra_info["rootdir"] = str(self.rootpath)
1265-
self._parser.extra_info["inifile"] = str(self.inipath)
1266-
self._parser.addini("addopts", "Extra command line options", "args")
1267-
self._parser.addini("minversion", "Minimally required pytest version")
1268-
self._parser.addini(
1269-
"pythonpath", type="paths", help="Add paths to sys.path", default=[]
1270-
)
1271-
self._parser.addini(
1272-
"required_plugins",
1273-
"Plugins that must be present for pytest to run",
1274-
type="args",
1275-
default=[],
1276-
)
1277-
12781249
def _consider_importhook(self, args: Sequence[str]) -> None:
12791250
"""Install the PEP 302 import hook if using assertion rewriting.
12801251
@@ -1399,7 +1370,35 @@ def _preparse(self, args: list[str], addopts: bool = True) -> None:
13991370
self._validate_args(shlex.split(env_addopts), "via PYTEST_ADDOPTS")
14001371
+ args
14011372
)
1402-
self._initini(args)
1373+
1374+
ns, unknown_args = self._parser.parse_known_and_unknown_args(
1375+
args, namespace=copy.copy(self.option)
1376+
)
1377+
rootpath, inipath, inicfg, ignored_config_files = determine_setup(
1378+
inifile=ns.inifilename,
1379+
override_ini=ns.override_ini,
1380+
args=ns.file_or_dir + unknown_args,
1381+
rootdir_cmd_arg=ns.rootdir or None,
1382+
invocation_dir=self.invocation_params.dir,
1383+
)
1384+
self._rootpath = rootpath
1385+
self._inipath = inipath
1386+
self._ignored_config_files = ignored_config_files
1387+
self.inicfg = inicfg
1388+
self._parser.extra_info["rootdir"] = str(self.rootpath)
1389+
self._parser.extra_info["inifile"] = str(self.inipath)
1390+
self._parser.addini("addopts", "Extra command line options", "args")
1391+
self._parser.addini("minversion", "Minimally required pytest version")
1392+
self._parser.addini(
1393+
"pythonpath", type="paths", help="Add paths to sys.path", default=[]
1394+
)
1395+
self._parser.addini(
1396+
"required_plugins",
1397+
"Plugins that must be present for pytest to run",
1398+
type="args",
1399+
default=[],
1400+
)
1401+
14031402
if addopts:
14041403
args[:] = (
14051404
self._validate_args(self.getini("addopts"), "via addopts config") + args

0 commit comments

Comments
 (0)