From 42a3cf6c30cf7b5240d44a856cfeae136a21cc59 Mon Sep 17 00:00:00 2001 From: rajdesai1510 <155978655+rajdesai1510@users.noreply.github.com> Date: Wed, 18 Feb 2026 17:40:28 +0530 Subject: [PATCH 1/2] Update default value for pythonpath ini option Update default value for pythonpath ini option allowing to pass rootdir path for running the pytest command from within a child folder but at the same time able to resolve the path for outside modules by passing the rootdir option. Without this change unable to run pytest for a particular file within the folder if it is importing from outside the cwd, resulting in unable to find the module. --- src/_pytest/config/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 21dc35219d8..9cf93bc4e99 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1518,7 +1518,7 @@ def parse(self, args: list[str], addopts: bool = True) -> None: self._parser.addini("addopts", "Extra command line options", "args") self._parser.addini("minversion", "Minimally required pytest version") self._parser.addini( - "pythonpath", type="paths", help="Add paths to sys.path", default=[] + "pythonpath", type="paths", help="Add paths to sys.path", default=[self._parser.extra_info["rootdir"]] ) self._parser.addini( "required_plugins", From af6296419c3784438cabb2b7b38ae8ca197e8862 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 12:16:36 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/_pytest/config/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 9cf93bc4e99..4a5796c7de7 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1518,7 +1518,10 @@ def parse(self, args: list[str], addopts: bool = True) -> None: self._parser.addini("addopts", "Extra command line options", "args") self._parser.addini("minversion", "Minimally required pytest version") self._parser.addini( - "pythonpath", type="paths", help="Add paths to sys.path", default=[self._parser.extra_info["rootdir"]] + "pythonpath", + type="paths", + help="Add paths to sys.path", + default=[self._parser.extra_info["rootdir"]], ) self._parser.addini( "required_plugins",