File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -362,6 +362,16 @@ def Config_inifile(self: pytest.Config) -> Optional[LEGACY_PATH]:
362
362
return legacy_path (str (self .inipath )) if self .inipath else None
363
363
364
364
365
+ def Session_stardir (self : pytest .Session ) -> LEGACY_PATH :
366
+ """The path from which pytest was invoked.
367
+
368
+ Prefer to use ``startpath`` which is a :class:`pathlib.Path`.
369
+
370
+ :type: LEGACY_PATH
371
+ """
372
+ return legacy_path (self .startpath )
373
+
374
+
365
375
def pytest_configure (config : pytest .Config ) -> None :
366
376
mp = pytest .MonkeyPatch ()
367
377
config .add_cleanup (mp .undo )
@@ -399,3 +409,6 @@ def pytest_configure(config: pytest.Config) -> None:
399
409
)
400
410
mp .setattr (pytest .Config , "rootdir" , property (Config_rootdir ), raising = False )
401
411
mp .setattr (pytest .Config , "inifile" , property (Config_inifile ), raising = False )
412
+
413
+ # Add Session.startdir property.
414
+ mp .setattr (pytest .Session , "startdir" , property (Session_stardir ), raising = False )
Original file line number Diff line number Diff line change 25
25
import _pytest ._code
26
26
from _pytest import nodes
27
27
from _pytest .compat import final
28
- from _pytest .compat import LEGACY_PATH
29
- from _pytest .compat import legacy_path
30
28
from _pytest .config import Config
31
29
from _pytest .config import directory_arg
32
30
from _pytest .config import ExitCode
@@ -504,16 +502,6 @@ def startpath(self) -> Path:
504
502
"""
505
503
return self .config .invocation_params .dir
506
504
507
- @property
508
- def stardir (self ) -> LEGACY_PATH :
509
- """The path from which pytest was invoked.
510
-
511
- Prefer to use ``startpath`` which is a :class:`pathlib.Path`.
512
-
513
- :type: LEGACY_PATH
514
- """
515
- return legacy_path (self .startpath )
516
-
517
505
def _node_location_to_relpath (self , node_path : Path ) -> str :
518
506
# bestrelpath is a quite slow function.
519
507
return self ._bestrelpathcache [node_path ]
You can’t perform that action at this time.
0 commit comments