File tree 2 files changed +20
-0
lines changed 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -447,6 +447,8 @@ def _prunetraceback(self, excinfo):
447
447
def _check_initialpaths_for_relpath (session , fspath ):
448
448
for initial_path in session ._initialpaths :
449
449
if fspath .common (initial_path ) == initial_path :
450
+ if initial_path .isdir ():
451
+ return fspath .relto (initial_path )
450
452
return fspath .relto (initial_path .dirname )
451
453
452
454
Original file line number Diff line number Diff line change
1
+ import py
2
+
1
3
import pytest
2
4
from _pytest import nodes
3
5
@@ -29,3 +31,19 @@ def test():
29
31
)
30
32
with pytest .raises (ValueError , match = ".*instance of PytestWarning.*" ):
31
33
items [0 ].warn (UserWarning ("some warning" ))
34
+
35
+
36
+ def test__check_initialpaths_for_relpath ():
37
+ """Ensure that it handles dirs, and does not always use dirname."""
38
+ d = py .path .local ()
39
+
40
+ class FakeSession :
41
+ _initialpaths = [d ]
42
+
43
+ assert nodes ._check_initialpaths_for_relpath (FakeSession , d ) == ""
44
+
45
+ f = d .join ("file" )
46
+ assert nodes ._check_initialpaths_for_relpath (FakeSession , f ) == "file"
47
+
48
+ outside = py .path .local ("/outside" )
49
+ assert nodes ._check_initialpaths_for_relpath (FakeSession , outside ) is None
You can’t perform that action at this time.
0 commit comments