File tree 2 files changed +22
-5
lines changed 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -547,11 +547,11 @@ def _compute_fixture_value(self, fixturedef):
547
547
if has_params :
548
548
frame = inspect .stack ()[3 ]
549
549
frameinfo = inspect .getframeinfo (frame [0 ])
550
- source_path = frameinfo .filename
550
+ source_path = py . path . local ( frameinfo .filename )
551
551
source_lineno = frameinfo .lineno
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 )
552
+ rel_source_path = source_path . relto ( funcitem . config . rootdir )
553
+ if rel_source_path :
554
+ source_path_str = rel_source_path
555
555
else :
556
556
source_path_str = str (source_path )
557
557
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