Skip to content

Commit 81a6f73

Browse files
committed
Fix "Plugin already registered" error with symlinks
Fixes pytest-dev#4174.
1 parent c94b2b2 commit 81a6f73

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/_pytest/config/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ def _getconftestmodules(self, path):
380380
if self._noconftest:
381381
return []
382382

383+
path = path.realpath()
383384
if path.isfile():
384385
directory = path.dirpath()
385386
else:

testing/test_conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ def pytest_addoption(parser):
192192
)
193193
def test_conftest_symlink(testdir):
194194
"""Ensure that conftest.py is used for resolved symlinks."""
195-
realtests = testdir.tmpdir.mkdir("real").mkdir("app").mkdir("tests")
195+
real = testdir.tmpdir.mkdir("real")
196+
realtests = real.mkdir("app").mkdir("tests")
196197
testdir.tmpdir.join("symlinktests").mksymlinkto(realtests)
198+
testdir.tmpdir.join("symlink").mksymlinkto(real)
197199
testdir.makepyfile(
198200
**{
199201
"real/app/tests/test_foo.py": "def test1(fixture): pass",
@@ -220,6 +222,10 @@ def fixture():
220222
)
221223
assert result.ret == EXIT_OK
222224

225+
# Should not cause "ValueError: Plugin already registered" (#4174).
226+
result = testdir.runpytest("-vs", "symlink")
227+
assert result.ret == EXIT_OK
228+
223229
realtests.ensure("__init__.py")
224230
result = testdir.runpytest("-vs", "symlinktests/test_foo.py::test1")
225231
result.stdout.fnmatch_lines(

0 commit comments

Comments
 (0)