Move Session.startdir to legacypath plugin
This commit is contained in:
parent
84722a7904
commit
d9ca55c648
|
@ -362,6 +362,16 @@ def Config_inifile(self: pytest.Config) -> Optional[LEGACY_PATH]:
|
|||
return legacy_path(str(self.inipath)) if self.inipath else None
|
||||
|
||||
|
||||
def Session_stardir(self: pytest.Session) -> LEGACY_PATH:
|
||||
"""The path from which pytest was invoked.
|
||||
|
||||
Prefer to use ``startpath`` which is a :class:`pathlib.Path`.
|
||||
|
||||
:type: LEGACY_PATH
|
||||
"""
|
||||
return legacy_path(self.startpath)
|
||||
|
||||
|
||||
def pytest_configure(config: pytest.Config) -> None:
|
||||
mp = pytest.MonkeyPatch()
|
||||
config.add_cleanup(mp.undo)
|
||||
|
@ -399,3 +409,6 @@ def pytest_configure(config: pytest.Config) -> None:
|
|||
)
|
||||
mp.setattr(pytest.Config, "rootdir", property(Config_rootdir), raising=False)
|
||||
mp.setattr(pytest.Config, "inifile", property(Config_inifile), raising=False)
|
||||
|
||||
# Add Session.startdir property.
|
||||
mp.setattr(pytest.Session, "startdir", property(Session_stardir), raising=False)
|
||||
|
|
|
@ -25,8 +25,6 @@ import attr
|
|||
import _pytest._code
|
||||
from _pytest import nodes
|
||||
from _pytest.compat import final
|
||||
from _pytest.compat import LEGACY_PATH
|
||||
from _pytest.compat import legacy_path
|
||||
from _pytest.config import Config
|
||||
from _pytest.config import directory_arg
|
||||
from _pytest.config import ExitCode
|
||||
|
@ -504,16 +502,6 @@ class Session(nodes.FSCollector):
|
|||
"""
|
||||
return self.config.invocation_params.dir
|
||||
|
||||
@property
|
||||
def stardir(self) -> LEGACY_PATH:
|
||||
"""The path from which pytest was invoked.
|
||||
|
||||
Prefer to use ``startpath`` which is a :class:`pathlib.Path`.
|
||||
|
||||
:type: LEGACY_PATH
|
||||
"""
|
||||
return legacy_path(self.startpath)
|
||||
|
||||
def _node_location_to_relpath(self, node_path: Path) -> str:
|
||||
# bestrelpath is a quite slow function.
|
||||
return self._bestrelpathcache[node_path]
|
||||
|
|
Loading…
Reference in New Issue