Skip to content

Commit 7c1ce06

Browse files
committed
config: add Config.{rootpath,inipath}, turn Config.{rootdir,inifile} to properties
1 parent eb1651e commit 7c1ce06

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/_pytest/config/__init__.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,22 @@ def invocation_dir(self) -> py.path.local:
919919
"""
920920
return py.path.local(str(self.invocation_params.dir))
921921

922+
@property
923+
def rootdir(self) -> py.path.local:
924+
"""The path to the :ref:`rootdir <rootdir>`.
925+
926+
:type: py.path.local
927+
"""
928+
return py.path.local(str(self.rootpath))
929+
930+
@property
931+
def inifile(self) -> Optional[py.path.local]:
932+
"""The path to the :ref:`configfile <configfiles>`.
933+
934+
:type: Optional[py.path.local]
935+
"""
936+
return py.path.local(str(self.inipath)) if self.inipath else None
937+
922938
def add_cleanup(self, func: Callable[[], None]) -> None:
923939
"""Add a function to be called when the config object gets out of
924940
use (usually coninciding with pytest_unconfigure)."""
@@ -1029,8 +1045,8 @@ def _initini(self, args: Sequence[str]) -> None:
10291045
rootdir_cmd_arg=ns.rootdir or None,
10301046
config=self,
10311047
)
1032-
self.rootdir = py.path.local(str(rootpath))
1033-
self.inifile = py.path.local(str(inipath)) if inipath else None
1048+
self.rootpath = rootpath
1049+
self.inipath = inipath
10341050
self.inicfg = inicfg
10351051
self._parser.extra_info["rootdir"] = self.rootdir
10361052
self._parser.extra_info["inifile"] = self.inifile

0 commit comments

Comments
 (0)