diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 96ead8509d6..d20fa3138d3 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -707,7 +707,7 @@ def _parsearg(self, arg): "file or package not found: " + arg + " (missing __init__.py?)" ) raise UsageError("file not found: " + arg) - parts[0] = path.realpath() + parts[0] = path return parts def matchnodes(self, matching, names): diff --git a/testing/test_collect_new.py b/testing/test_collect_new.py new file mode 100644 index 00000000000..a61e5aa0d11 --- /dev/null +++ b/testing/test_collect_new.py @@ -0,0 +1,17 @@ +def test_symlink_in_sandbox(testdir): + appdir = testdir.mkdir("app") + testdir.makepyfile( + **{ + "app/__init__.py": """import pleasedontimportme""", + "app/test.py": """ + def test_pass(): + pass + """, + } + ) + sandbox = testdir.mkdir("sandbox") + symlink = sandbox.join("test_symlink.py") + symlink.mksymlinkto(appdir.join("test.py")) + + result = testdir.runpytest(str(symlink)) + result.stdout.fnmatch_lines(["*= 1 passed in *="])