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):
550550 source_path = frameinfo .filename
551551 source_lineno = frameinfo .lineno
552552 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
555556 else :
556557 source_path_str = str (source_path )
557558 msg = (
Original file line number Diff line number Diff line change @@ -3662,13 +3662,30 @@ def test_foo(request):
36623662 " test_foos.py::test_foo" ,
36633663 "" ,
36643664 "Requested fixture 'fix_with_param' defined in:" ,
3665- "*fix.py :4" ,
3665+ "{} :4" . format ( fixfile ) ,
36663666 "Requested here:" ,
36673667 "test_foos.py:4" ,
36683668 "*1 failed*" ,
36693669 ]
36703670 )
36713671
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+
36723689
36733690def test_pytest_fixture_setup_and_post_finalizer_hook (testdir ):
36743691 testdir .makeconftest (
You can’t perform that action at this time.
0 commit comments