File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -550,8 +550,9 @@ def _compute_fixture_value(self, fixturedef):
550
550
source_path = frameinfo .filename
551
551
source_lineno = frameinfo .lineno
552
552
source_path = py .path .local (source_path )
553
- if source_path .relto (funcitem .config .rootdir ):
554
- source_path_str = source_path .relto (funcitem .config .rootdir )
553
+ rel_source_path = source_path .relto (funcitem .config .rootdir )
554
+ if rel_source_path :
555
+ source_path_str = rel_source_path
555
556
else :
556
557
source_path_str = str (source_path )
557
558
msg = (
Original file line number Diff line number Diff line change @@ -3662,13 +3662,30 @@ def test_foo(request):
3662
3662
" test_foos.py::test_foo" ,
3663
3663
"" ,
3664
3664
"Requested fixture 'fix_with_param' defined in:" ,
3665
- "*fix.py :4" ,
3665
+ "{} :4" . format ( fixfile ) ,
3666
3666
"Requested here:" ,
3667
3667
"test_foos.py:4" ,
3668
3668
"*1 failed*" ,
3669
3669
]
3670
3670
)
3671
3671
3672
+ # With non-overlapping rootdir, passing tests_dir.
3673
+ rootdir = testdir .mkdir ("rootdir" )
3674
+ rootdir .chdir ()
3675
+ result = testdir .runpytest ("--rootdir" , rootdir , tests_dir )
3676
+ result .stdout .fnmatch_lines (
3677
+ [
3678
+ "The requested fixture has no parameter defined for test:" ,
3679
+ " test_foos.py::test_foo" ,
3680
+ "" ,
3681
+ "Requested fixture 'fix_with_param' defined in:" ,
3682
+ "{}:4" .format (fixfile ),
3683
+ "Requested here:" ,
3684
+ "{}:4" .format (testfile ),
3685
+ "*1 failed*" ,
3686
+ ]
3687
+ )
3688
+
3672
3689
3673
3690
def test_pytest_fixture_setup_and_post_finalizer_hook (testdir ):
3674
3691
testdir .makeconftest (
You can’t perform that action at this time.
0 commit comments