Merge pull request #4214 from blueyed/fix-4174
Fix "Plugin already registered" error with symlinks
This commit is contained in:
commit
72d98a7c52
|
@ -0,0 +1 @@
|
|||
Fix "ValueError: Plugin already registered" with conftest plugins via symlink.
|
|
@ -391,7 +391,7 @@ class PytestPluginManager(PluginManager):
|
|||
# and allow users to opt into looking into the rootdir parent
|
||||
# directories instead of requiring to specify confcutdir
|
||||
clist = []
|
||||
for parent in directory.parts():
|
||||
for parent in directory.realpath().parts():
|
||||
if self._confcutdir and self._confcutdir.relto(parent):
|
||||
continue
|
||||
conftestpath = parent.join("conftest.py")
|
||||
|
|
|
@ -192,8 +192,10 @@ def test_conftest_confcutdir(testdir):
|
|||
)
|
||||
def test_conftest_symlink(testdir):
|
||||
"""Ensure that conftest.py is used for resolved symlinks."""
|
||||
realtests = testdir.tmpdir.mkdir("real").mkdir("app").mkdir("tests")
|
||||
real = testdir.tmpdir.mkdir("real")
|
||||
realtests = real.mkdir("app").mkdir("tests")
|
||||
testdir.tmpdir.join("symlinktests").mksymlinkto(realtests)
|
||||
testdir.tmpdir.join("symlink").mksymlinkto(real)
|
||||
testdir.makepyfile(
|
||||
**{
|
||||
"real/app/tests/test_foo.py": "def test1(fixture): pass",
|
||||
|
@ -220,6 +222,10 @@ def test_conftest_symlink(testdir):
|
|||
)
|
||||
assert result.ret == EXIT_OK
|
||||
|
||||
# Should not cause "ValueError: Plugin already registered" (#4174).
|
||||
result = testdir.runpytest("-vs", "symlink")
|
||||
assert result.ret == EXIT_OK
|
||||
|
||||
realtests.ensure("__init__.py")
|
||||
result = testdir.runpytest("-vs", "symlinktests/test_foo.py::test1")
|
||||
result.stdout.fnmatch_lines(
|
||||
|
|
Loading…
Reference in New Issue