New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Import file mismatch" at test collection time #12123
Comments
Hi @lelit, thanks for the report. I could not reproduce the issue however, here is my file tree:
(all files are empty) This runs pytest file for me (with zero collected tests of course). Can you try to provide a minimal working example? |
Oh! I will try to distill an MWE, but for now a relatively quick (it takes a couple of minutes in total) recipe is:
The above works ok, producing
Then if I do
I get the following instead:
As said, I will try to minimize it. In the meantime, thanks for your time! |
Thanks! Same here: https://github.com/xflr6/graphviz/actions/runs/8317341967 (with multiple |
If that's any help, I was able to workaround the problem by specifying |
Hi, a little update: as promised I tried to come up with an MWE that exhibits the problem, but so far I had no luck in isolating the condition that triggers it. In another, even bigger project I wrote and maintain it does not happen, and neither in a very simplicistic mock, similar to what @nicoddemus did above, but with not completely empty files (test units and conftest.py). |
I suspect |
Thanks, I will take that into consideration, even if the other project I mentioned uses doctests as well but does not manifest the problem. |
Version 0.20.3 -------------- Revert improvements to the internal ``tools.deprecate_positional_args()`` decorator that caused false positive ``PendingDeprecationWarning: The signature of ... will be reduced`` warnings that have been misinterpreted in the 0.20.2 release process. Version 0.20.2 -------------- Drop Python 3.7 support (end of life 27 Jun 2023). Tag Python 3.11 and 3.12 support. Add caveat about ``labe`` escaping/quoting to ``.node()`` and ``.render()`` API docs. Document that ``doctest_skip_exe()`` lines in doctest should be ignored. Improve internal ``tools.deprecate_positional_args()`` decorator and fix incorect test assertion. Update GitHub actions. Pin ``pytest`` test dependency to ``<8.1`` as a workaround for ``import file mismatch error`` related to ``conftest.py`` files, in ``pytest 8.1.1``, see pytest-dev/pytest#12123.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
To avoid confusion, see e.g. #12123 (comment)
To avoid confusion, see e.g. #12123 (comment) Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
I'm sorry, I could not reserve some spare time to further investigate the issue, trying to condense a standalone replication recipe. |
To avoid confusion, see e.g. pytest-dev#12123 (comment) Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
To avoid confusion, see e.g. pytest-dev#12123 (comment) Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
While I was not able to distill a repeatable MWE recipe, I executed a git bisect start
git bisect bad 8.2.0
git bisect good 8.0.2
git run sh run.sh where pip install -U .
cd ~/wip/sol5/
pytest --collect-only The final outcome is the following:
Hope this brings some enlightenment. |
I tried to upgrade pytest from 8.0.2 to latest 8.1.1 and I got this error:
Neither removing all
__pycache__
subdirs, nor playing with the--import-mode
option fixed it.The top level
tests
directory contains this structure:and there are different
conftest.py
modules:Given that I could not find a related breaking change alert, I'd say that the "use a unique basename for your test file modules" hint does not apply to
conftest.py
, right?Thanks&bye.
Environment
I'm using Python 3.11.8 on a Debian
sid
, with the following packages in the virtual environment (after downgradingpytest
to the working8.0.2
):The text was updated successfully, but these errors were encountered: