Test discovery finds module that doesn't exist #9586
Labels
plugin: doctests
related to the doctests builtin plugin
topic: collection
related to the collection phase
type: bug
problem that needs to be addressed
In jaraco/inflect#135, the contributor has accidentally misnamed the package. They attempted to rename
inflect
(module) toinflect
(package). Instead, by accident, they renamedinflect
toinflect.inflect
and as a result, created an emptyinflect
module (as a namespace package). I would have expected the tests to fail, but they did not. Something about the test collection caused pytest to findinflect/inflect.py
as the top-levelinflect
module, masking the mistake.troubleshooting
I tried to create a minimal reproducer, but the reproducer fails as expected:
I'm confident that one of the plugins (doctests, mypy, black, flake8, ...) is probably implicated, but when I try to enable doctests, I get another error:
It seems that error is occurring because
inflect
is discovered as a namespace package, but doesn't have a__file__
attribute.I found that I could minimally reproduce the non-failure by (a) putting the test in a subdirectory and (b) invoking doctests.
As you can see, the test passes, even though the 'inflect' module should have only been found at
inflect.inflect
. Remove the--doctest-modules
and the expected failure occurs:I'm fairly certain this missed failure is just another manifestation of #3396 and #8332. In this case, the namespace package was an accident.
The text was updated successfully, but these errors were encountered: