Consider the following (simple) project structure :
taxidriver
|-- src
| |-- __init__.py
| |-- libtaxi.py
| |-- libformat.py
| |-- app.py
|-- tests
|-- __init__.py
|-- test_taxi.py
|-- test_format.py
|-- test_integration.py
My issue is related to pytest always sending ImportError while importing test module $Rightarrow$ ModuleNotFoundError: No module named 'src.libtaxi'.
- In the
libformat.py
I call the imports like so :
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from rich.table import Table
from rich.markdown import Markdown
from src import libtaxi as lt
- In the
app.py
I call the imports like so :
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
import typer
from taxidriver import libtaxi as lt
from taxidriver import libformat as lf
- The imports inside the tests folder from file
test_format
:
from src.libtaxi import (
Emplacement,
Itineraire,
Ville,
)
from src.libformat import format_emplacement, format_routes, format_trajet
Note that relative imports yields the same results as absolute imports and sends back an import module Error. Is there an issue with my imports ?