File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1+ Fix collection of direct symlinked files.
Original file line number Diff line number Diff line change @@ -488,7 +488,7 @@ def _collect(self, arg):
488488 from _pytest .python import Package
489489
490490 names = self ._parsearg (arg )
491- argpath = names .pop (0 ). realpath ()
491+ argpath = names .pop (0 )
492492
493493 # Start with a Session root, and delve to argpath item (dir or file)
494494 # and stack all Packages found on the way.
@@ -636,7 +636,7 @@ def _parsearg(self, arg):
636636 "file or package not found: " + arg + " (missing __init__.py?)"
637637 )
638638 raise UsageError ("file not found: " + arg )
639- parts [0 ] = path
639+ parts [0 ] = path . realpath ()
640640 return parts
641641
642642 def matchnodes (self , matching , names ):
Original file line number Diff line number Diff line change 66import sys
77import textwrap
88
9+ import py
10+
911import pytest
1012from _pytest .main import _in_venv
1113from _pytest .main import EXIT_NOTESTSCOLLECTED
@@ -1051,3 +1053,16 @@ def test_1():
10511053 result = testdir .runpytest ()
10521054 assert result .ret == 0
10531055 result .stdout .fnmatch_lines (["*1 passed in*" ])
1056+
1057+
1058+ @pytest .mark .skipif (
1059+ not hasattr (py .path .local , "mksymlinkto" ),
1060+ reason = "symlink not available on this platform" ,
1061+ )
1062+ def test_collect_symlink_file_arg (testdir ):
1063+ """Test that collecting a direct symlink works (#4325)."""
1064+ p = testdir .makepyfile ("def test_1(): pass" )
1065+ testdir .tmpdir .join ("symlink.py" ).mksymlinkto (p )
1066+ result = testdir .runpytest ("--collect-only" , "symlink.py" )
1067+ result .stdout .fnmatch_lines (["collected 1 item" ])
1068+ assert result .ret == 0
You can’t perform that action at this time.
0 commit comments