Skip to content

Commit 42a3cf6

Browse files
authored
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.
1 parent f081bfb commit 42a3cf6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/_pytest/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1518,7 +1518,7 @@ def parse(self, args: list[str], addopts: bool = True) -> None:
15181518
self._parser.addini("addopts", "Extra command line options", "args")
15191519
self._parser.addini("minversion", "Minimally required pytest version")
15201520
self._parser.addini(
1521-
"pythonpath", type="paths", help="Add paths to sys.path", default=[]
1521+
"pythonpath", type="paths", help="Add paths to sys.path", default=[self._parser.extra_info["rootdir"]]
15221522
)
15231523
self._parser.addini(
15241524
"required_plugins",

0 commit comments

Comments
 (0)