this is my project structure (just an example to illustrate the problem):
.
├── hello_world
│ ├── __init__.py
│ └── some
│ └── very_nested
│ └── stuff.py
└── tests
└── test_stuff.py
The test_stuff.py
file (for py.test
):
from hello_world.some.very_nested.stuff import Magic
from hello_world.some.very_nested.other_stuff import MoreMagic
def test_magic_fact_works():
assert Magic().fact(3) == 6
# ...
Is there any way how to make the import lines shorter? They get too long in the real project.
For example, this would be nice, but it doesn't work :)
import hello_world.some.very_nested as vn
from vn.stuff import Magic
from vn.other_stuff import MoreMagic
I cannot use relative imports (I assume) beucase the tests are not inside the package. I could move them, but is it possible without changing project structure?
Aucun commentaire:
Enregistrer un commentaire