Hello, i have build some custom extractors and wou...
# troubleshooting
e
Hello, i have build some custom extractors and would like to test them. I am getting a
ModuleNotFoundError: No module named 'tests.test_core_lightfoot'
. There is also the hint:
Hint: make sure your test modules/packages have valid Python names.
.I am running pytest from meltano root directory. Any ideas why this happens?
🆘 1
r
Can you share you project structure?
e
meltano/extract/tap-lightfoot/tests/test_core_lightfoot.py
r
How are you running pytest?
e
Just pytest from the root directory. The test for another plugin runs fine. it is under meltano/extract/tap-lightfoot/tests/test_core.py. I did not change the name there and it runs just fine. All the others throuw errors
r
Does
pytest tests/test_core_lightfoot.py
work? Are you importing from
tests.test_core_lightfoot
somewhere? This works for me:
e
The test itself works fine. I am not importing it.
pytest extract/tap-lightfoot/tests/test_core_lightfoot.py works fine
r
It also runs fine with all tests. What if you run the command from in the
tap-lightfoot
directory?
e
Inside the directory it runs as well. I have 4 plugins and all have tests. If i delete the test from all the plugins but one it will also run. As soon as the test is added to the other plugin it will throw an error
r
Tbh, I don't know what the implications of running pytest for multiple Python projects is. If I emulate your setup, I get a bunch of `ModuleNotFoundError`s during test collection - presumably because each project has its own set of dependencies managed by a Poetry venv.
e
Had that as well. Added the dependencies to toml test dependecies and it runs
r
Like a top-level
pyproject.toml
in the project root with test dependencies for all plugins?
e
Yes and have also set the pythonpath to use root pypackages as everything needed for the tests is in there
Pytest iterates through the plugins, it runs the first test that it finds and everything after that will fail
r
That setup sounds pretty wild, so it doesn't surprise me that you are running into problems. Maybe someone else can help, sorry.
e
Yeah it is a bit wild. Only facing the problem with tests. Maybe i will find a solution. Still many thanks for trying
😅 1