@@ -972,11 +972,31 @@ def _initini(self, args):
972
972
ns , unknown_args = self ._parser .parse_known_and_unknown_args (args , namespace = self .option .copy ())
973
973
r = determine_setup (ns .inifilename , ns .file_or_dir + unknown_args , warnfunc = self .warn )
974
974
self .rootdir , self .inifile , self .inicfg = r
975
- self ._parser .extra_info ['rootdir' ] = self .rootdir
976
- self ._parser .extra_info ['inifile' ] = self .inifile
977
- self .invocation_dir = py .path .local ()
978
975
self ._parser .addini ('addopts' , 'extra command line options' , 'args' )
979
976
self ._parser .addini ('minversion' , 'minimally required pytest version' )
977
+ self ._parser .addini ('pathtype' , 'path implementation to be used' , default = 'pylib' )
978
+
979
+ self .invocation_dir = self .make_path ()
980
+ self .rootdir = self .make_path (self .rootdir )
981
+ self .inifile = self .make_path (self .inifile )
982
+ self ._parser .extra_info ['rootdir' ] = self .rootdir
983
+ self ._parser .extra_info ['inifile' ] = self .inifile
984
+
985
+ def make_path (self , input = None ):
986
+ if input is None :
987
+ input = os .getcwd ()
988
+ pathtype = self .getini ('pathtype' )
989
+ if pathtype == 'pylib' :
990
+ return py .path .local (input )
991
+ elif pathtype == 'pathlib' :
992
+ # for pythons that dont use fspath
993
+ if isinstance (input , py .path .local ):
994
+ input = str (input )
995
+ import pathlib
996
+ return pathlib .Path (input )
997
+ elif pathtype == 'pathlib2' :
998
+ import pathlib2
999
+ return pathlib2 .Path (input )
980
1000
981
1001
def _consider_importhook (self , args , entrypoint_name ):
982
1002
"""Install the PEP 302 import hook if using assertion re-writing.
@@ -1311,7 +1331,7 @@ def determine_setup(inifile, args, warnfunc=None):
1311
1331
if rootdir is None :
1312
1332
rootdir = get_common_ancestor ([py .path .local (), ancestor ])
1313
1333
is_fs_root = os .path .splitdrive (str (rootdir ))[1 ] == os .sep
1314
- if is_fs_root :
1334
+ if is_fs_root :
1315
1335
rootdir = ancestor
1316
1336
return rootdir , inifile , inicfg or {}
1317
1337
0 commit comments