Open
Description
Dear Pytest team,
I’ve encountered a bug on Windows where conftest.py is loaded multiple times if the path to the test files is specified with differing case on a case-insensitive file system. This behavior triggers the following error (on minimal reproduction example) - ValueError: option names {'--dummy-option'} already added
Minimal reproduction example:
Steps to reproduce:
unzip pytest_bug.zip
python -m pytest .\pytest_bug\Reproducer\
(note that runningpython -m pytest .\pytest_bug\reproducer\
will finish with 0 collected tests as expected)
Pip list output and OS version
OS version: Windows 11
Python Version: 3.12.9
(.venv) PS C:\venvs\reproducer\pytest_bug> python -m pip list
Package Version
--------- -------
colorama 0.4.6
iniconfig 2.0.0
packaging 24.2
pip 24.3.1
pluggy 1.5.0
pytest 8.3.5
Potentional fix
Resolving the path fixes the issue, but I am not sure whether it might not have impact on something else.
$ git diff
diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py
index 56b047196..39f61daaf 100644
--- a/src/_pytest/config/__init__.py
+++ b/src/_pytest/config/__init__.py
@@ -643,7 +643,7 @@ class PytestPluginManager(PluginManager):
if self._noconftest:
return
- directory = self._get_directory(path)
+ directory = self._get_directory(path.resolve())
Thank you.