| 1510 | return self._inicfg.keys() - known_keys |
| 1511 | |
| 1512 | def parse(self, args: list[str], addopts: bool = True) -> None: |
| 1513 | # Parse given cmdline arguments into this config object. |
| 1514 | assert self.args == [], ( |
| 1515 | "can only parse cmdline args at most once per Config object" |
| 1516 | ) |
| 1517 | |
| 1518 | self.hook.pytest_addhooks.call_historic( |
| 1519 | kwargs=dict(pluginmanager=self.pluginmanager) |
| 1520 | ) |
| 1521 | |
| 1522 | if addopts: |
| 1523 | env_addopts = os.environ.get("PYTEST_ADDOPTS", "") |
| 1524 | if len(env_addopts): |
| 1525 | args[:] = ( |
| 1526 | self._validate_args(shlex.split(env_addopts), "via PYTEST_ADDOPTS") |
| 1527 | + args |
| 1528 | ) |
| 1529 | |
| 1530 | # At this point, self.option contains only defaults from the _processopt |
| 1531 | # callback. |
| 1532 | ns = self._parser.parse_known_args(args, namespace=copy.copy(self.option)) |
| 1533 | rootpath, inipath, inicfg, ignored_config_files = determine_setup( |
| 1534 | inifile=ns.inifilename, |
| 1535 | override_ini=ns.override_ini, |
| 1536 | args=ns.file_or_dir, |
| 1537 | rootdir_cmd_arg=ns.rootdir or None, |
| 1538 | invocation_dir=self.invocation_params.dir, |
| 1539 | ) |
| 1540 | self._rootpath = rootpath |
| 1541 | self._inipath = inipath |
| 1542 | self._ignored_config_files = ignored_config_files |
| 1543 | self._inicfg = inicfg |
| 1544 | self._parser.extra_info["rootdir"] = str(self.rootpath) |
| 1545 | self._parser.extra_info["inifile"] = str(self.inipath) |
| 1546 | |
| 1547 | self._parser.addini("addopts", "Extra command line options", "args") |
| 1548 | self._parser.addini("minversion", "Minimally required pytest version") |
| 1549 | self._parser.addini( |
| 1550 | "pythonpath", type="paths", help="Add paths to sys.path", default=[] |
| 1551 | ) |
| 1552 | self._parser.addini( |
| 1553 | "required_plugins", |
| 1554 | "Plugins that must be present for pytest to run", |
| 1555 | type="args", |
| 1556 | default=[], |
| 1557 | ) |
| 1558 | |
| 1559 | if addopts: |
| 1560 | args[:] = ( |
| 1561 | self._validate_args(self.getini("addopts"), "via addopts config") + args |
| 1562 | ) |
| 1563 | |
| 1564 | self.known_args_namespace = self._parser.parse_known_args( |
| 1565 | args, namespace=copy.copy(self.option) |
| 1566 | ) |
| 1567 | if addopts: |
| 1568 | # addopts may have added overrides (especially via OverrideIniAction). |
| 1569 | # The thing can be endlessly circular but we only do one level (#14442). |