Skip to content

Commit 6a174af

Browse files
committed
terminal: move startdir attribute to a property that can be deprecated
Same as in Config.
1 parent e515264 commit 6a174af

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/_pytest/terminal.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
from _pytest._code.code import ExceptionRepr
3838
from _pytest._io.wcwidth import wcswidth
3939
from _pytest.compat import final
40+
from _pytest.compat import LEGACY_PATH
41+
from _pytest.compat import legacy_path
4042
from _pytest.config import _PluggyPlugin
4143
from _pytest.config import Config
4244
from _pytest.config import ExitCode
@@ -318,7 +320,6 @@ def __init__(self, config: Config, file: Optional[TextIO] = None) -> None:
318320
self.stats: Dict[str, List[Any]] = {}
319321
self._main_color: Optional[str] = None
320322
self._known_types: Optional[List[str]] = None
321-
self.startdir = config.invocation_dir
322323
self.startpath = config.invocation_params.dir
323324
if file is None:
324325
file = sys.stdout
@@ -381,6 +382,16 @@ def showfspath(self, value: Optional[bool]) -> None:
381382
def showlongtestinfo(self) -> bool:
382383
return self.verbosity > 0
383384

385+
@property
386+
def startdir(self) -> LEGACY_PATH:
387+
"""The directory from which pytest was invoked.
388+
389+
Prefer to use ``startpath`` which is a :class:`pathlib.Path`.
390+
391+
:type: LEGACY_PATH
392+
"""
393+
return legacy_path(self.startpath)
394+
384395
def hasopt(self, char: str) -> bool:
385396
char = {"xfailed": "x", "skipped": "s"}.get(char, char)
386397
return char in self.reportchars

0 commit comments

Comments
 (0)