|
37 | 37 | from _pytest._code.code import ExceptionRepr
|
38 | 38 | from _pytest._io.wcwidth import wcswidth
|
39 | 39 | from _pytest.compat import final
|
| 40 | +from _pytest.compat import LEGACY_PATH |
| 41 | +from _pytest.compat import legacy_path |
40 | 42 | from _pytest.config import _PluggyPlugin
|
41 | 43 | from _pytest.config import Config
|
42 | 44 | from _pytest.config import ExitCode
|
@@ -318,7 +320,6 @@ def __init__(self, config: Config, file: Optional[TextIO] = None) -> None:
|
318 | 320 | self.stats: Dict[str, List[Any]] = {}
|
319 | 321 | self._main_color: Optional[str] = None
|
320 | 322 | self._known_types: Optional[List[str]] = None
|
321 |
| - self.startdir = config.invocation_dir |
322 | 323 | self.startpath = config.invocation_params.dir
|
323 | 324 | if file is None:
|
324 | 325 | file = sys.stdout
|
@@ -381,6 +382,16 @@ def showfspath(self, value: Optional[bool]) -> None:
|
381 | 382 | def showlongtestinfo(self) -> bool:
|
382 | 383 | return self.verbosity > 0
|
383 | 384 |
|
| 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 | + |
384 | 395 | def hasopt(self, char: str) -> bool:
|
385 | 396 | char = {"xfailed": "x", "skipped": "s"}.get(char, char)
|
386 | 397 | return char in self.reportchars
|
|
0 commit comments