You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my bases and component files, I use the truncated style of import, e.g. from my_app.foo import my_func, rather than from bases.my_app.foo import my_func or from components.my_app.bar import whatever.
This works well and my IDE can pick it up.
However, pytest is having issues with it. I tried setting my pytest options in pyproject.toml to:
But the pytest runner can only ever handle truncated imports from the first element in the pythonpath list.
My work around is to just do pythonpath = "components", and then if a test needs to import something from a base file, I do from bases.my_app.foo instead of from my_app.foo.
But I wondered if anyone else has run into this issue, and knows a way of setting up the config so that I can use truncated style imports everywhere in my repo?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Seasons greetings, all!
I'm having some import issues with pytest.
In my bases and component files, I use the truncated style of import, e.g.
from my_app.foo import my_func
, rather thanfrom bases.my_app.foo import my_func
orfrom components.my_app.bar import whatever
.This works well and my IDE can pick it up.
However, pytest is having issues with it. I tried setting my pytest options in
pyproject.toml
to:But the pytest runner can only ever handle truncated imports from the first element in the pythonpath list.
My work around is to just do
pythonpath = "components"
, and then if a test needs to import something from a base file, I dofrom bases.my_app.foo
instead offrom my_app.foo
.But I wondered if anyone else has run into this issue, and knows a way of setting up the config so that I can use truncated style imports everywhere in my repo?
Beta Was this translation helpful? Give feedback.
All reactions