File tree Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 14
14
from _pytest .compat import LEGACY_PATH
15
15
from _pytest .compat import legacy_path
16
16
from _pytest .deprecated import check_ispytest
17
+ from _pytest .terminal import TerminalReporter
17
18
18
19
if TYPE_CHECKING :
19
20
from typing_extensions import Final
@@ -320,6 +321,16 @@ def FixtureRequest_fspath(self: pytest.FixtureRequest) -> LEGACY_PATH:
320
321
return legacy_path (self .path )
321
322
322
323
324
+ def TerminalReporter_startdir (self : TerminalReporter ) -> LEGACY_PATH :
325
+ """The directory from which pytest was invoked.
326
+
327
+ Prefer to use ``startpath`` which is a :class:`pathlib.Path`.
328
+
329
+ :type: LEGACY_PATH
330
+ """
331
+ return legacy_path (self .startpath )
332
+
333
+
323
334
def pytest_configure (config : pytest .Config ) -> None :
324
335
mp = pytest .MonkeyPatch ()
325
336
config .add_cleanup (mp .undo )
@@ -345,3 +356,8 @@ def pytest_configure(config: pytest.Config) -> None:
345
356
mp .setattr (
346
357
pytest .FixtureRequest , "fspath" , property (FixtureRequest_fspath ), raising = False
347
358
)
359
+
360
+ # Add TerminalReporter.startdir property.
361
+ mp .setattr (
362
+ TerminalReporter , "startdir" , property (TerminalReporter_startdir ), raising = False
363
+ )
Original file line number Diff line number Diff line change 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
42
40
from _pytest .config import _PluggyPlugin
43
41
from _pytest .config import Config
44
42
from _pytest .config import ExitCode
@@ -383,16 +381,6 @@ def showfspath(self, value: Optional[bool]) -> None:
383
381
def showlongtestinfo (self ) -> bool :
384
382
return self .verbosity > 0
385
383
386
- @property
387
- def startdir (self ) -> LEGACY_PATH :
388
- """The directory from which pytest was invoked.
389
-
390
- Prefer to use ``startpath`` which is a :class:`pathlib.Path`.
391
-
392
- :type: LEGACY_PATH
393
- """
394
- return legacy_path (self .startpath )
395
-
396
384
def hasopt (self , char : str ) -> bool :
397
385
char = {"xfailed" : "x" , "skipped" : "s" }.get (char , char )
398
386
return char in self .reportchars
You can’t perform that action at this time.
0 commit comments