4949from _pytest ._io import TerminalWriter
5050from _pytest .compat import final
5151from _pytest .compat import importlib_metadata
52- from _pytest .compat import LEGACY_PATH
53- from _pytest .compat import legacy_path
5452from _pytest .outcomes import fail
5553from _pytest .outcomes import Skipped
5654from _pytest .pathlib import absolutepath
@@ -240,6 +238,7 @@ def directory_arg(path: str, optname: str) -> str:
240238 "unittest" ,
241239 "capture" ,
242240 "skipping" ,
241+ "legacypath" ,
243242 "tmpdir" ,
244243 "monkeypatch" ,
245244 "recwarn" ,
@@ -949,17 +948,6 @@ def __init__(
949948
950949 self .cache : Optional [Cache ] = None
951950
952- @property
953- def invocation_dir (self ) -> LEGACY_PATH :
954- """The directory from which pytest was invoked.
955-
956- Prefer to use :attr:`invocation_params.dir <InvocationParams.dir>`,
957- which is a :class:`pathlib.Path`.
958-
959- :type: LEGACY_PATH
960- """
961- return legacy_path (str (self .invocation_params .dir ))
962-
963951 @property
964952 def rootpath (self ) -> Path :
965953 """The path to the :ref:`rootdir <rootdir>`.
@@ -970,16 +958,6 @@ def rootpath(self) -> Path:
970958 """
971959 return self ._rootpath
972960
973- @property
974- def rootdir (self ) -> LEGACY_PATH :
975- """The path to the :ref:`rootdir <rootdir>`.
976-
977- Prefer to use :attr:`rootpath`, which is a :class:`pathlib.Path`.
978-
979- :type: LEGACY_PATH
980- """
981- return legacy_path (str (self .rootpath ))
982-
983961 @property
984962 def inipath (self ) -> Optional [Path ]:
985963 """The path to the :ref:`configfile <configfiles>`.
@@ -990,16 +968,6 @@ def inipath(self) -> Optional[Path]:
990968 """
991969 return self ._inipath
992970
993- @property
994- def inifile (self ) -> Optional [LEGACY_PATH ]:
995- """The path to the :ref:`configfile <configfiles>`.
996-
997- Prefer to use :attr:`inipath`, which is a :class:`pathlib.Path`.
998-
999- :type: Optional[LEGACY_PATH]
1000- """
1001- return legacy_path (str (self .inipath )) if self .inipath else None
1002-
1003971 def add_cleanup (self , func : Callable [[], None ]) -> None :
1004972 """Add a function to be called when the config object gets out of
1005973 use (usually coninciding with pytest_unconfigure)."""
@@ -1400,6 +1368,12 @@ def getini(self, name: str):
14001368 self ._inicache [name ] = val = self ._getini (name )
14011369 return val
14021370
1371+ # Meant for easy monkeypatching by legacypath plugin.
1372+ # Can be inlined back (with no cover removed) once legacypath is gone.
1373+ def _getini_unknown_type (self , name : str , type : str , value : Union [str , List [str ]]):
1374+ msg = f"unknown configuration type: { type } "
1375+ raise ValueError (msg , value ) # pragma: no cover
1376+
14031377 def _getini (self , name : str ):
14041378 try :
14051379 description , type , default = self ._parser ._inidict [name ]
@@ -1432,13 +1406,7 @@ def _getini(self, name: str):
14321406 # a_line_list = ["tests", "acceptance"]
14331407 # in this case, we already have a list ready to use.
14341408 #
1435- if type == "pathlist" :
1436- # TODO: This assert is probably not valid in all cases.
1437- assert self .inipath is not None
1438- dp = self .inipath .parent
1439- input_values = shlex .split (value ) if isinstance (value , str ) else value
1440- return [legacy_path (str (dp / x )) for x in input_values ]
1441- elif type == "paths" :
1409+ if type == "paths" :
14421410 # TODO: This assert is probably not valid in all cases.
14431411 assert self .inipath is not None
14441412 dp = self .inipath .parent
@@ -1453,9 +1421,12 @@ def _getini(self, name: str):
14531421 return value
14541422 elif type == "bool" :
14551423 return _strtobool (str (value ).strip ())
1456- else :
1457- assert type in [None , "string" ]
1424+ elif type == "string" :
1425+ return value
1426+ elif type is None :
14581427 return value
1428+ else :
1429+ return self ._getini_unknown_type (name , type , value )
14591430
14601431 def _getconftest_pathlist (
14611432 self , name : str , path : Path , rootpath : Path
0 commit comments