Presence of empty __init__.py
breaks test discovery in hard-to-diagnose ways
#9300
Labels
topic: collection
related to the collection phase
Hey all
I'm trying to add another package to conda-forge, and ran into collection problems when attempting to run the upstream test suite:
The first thing that caught my eye were the weird kind of test wrappers that tf-addons is using (my guess from searching their repo is that this is for bazel compatibility, and hence not so relevant due to the relative rarity of that in python; edit: beyond the convoluted definition, the underlying issue for these is #9301), but removing those still left me with similarly cryptic errors:
I then got curious about
No module named 'tests.avg_model_checkpoint_test'
, especially because the upstream test modules (an example) looked alright, and that module that was supposedly not being found didn't appeared anywhere.By chance, I noticed that the test folders contain empty
__init__.py
files, and due to some dim awareness of the issues around imports, I decided on a whim to see what happens if I remove them - turns out collection succeeds then! 🥳From looking around the issue tracker (and said awareness of import troubles in python), I believe this issue is probably quite thorny, so the underlying problem is probably captured in other issues already: #3396 #5147 #8332
However, I'm hoping that a possible fix for empty
__init__.py
might be easier than that, and at the very least, I think the warning should be improved, because it's really not obvious what's causing the problem.The text was updated successfully, but these errors were encountered: