This is my folder structure:
tree -L 2
.
├── Pipfile
├── Pipfile.lock
├── Procfile
├── README.md
├── __init__.py
├── __pycache__
│ └── __init__.cpython-37.pyc
├── alembic
│ ├── README
│ ├── env.py
│ ├── script.py.mako
│ └── versions
├── clients
│ ├── __init__.py
│ ├── __pycache__
│ ├── binance_client.py
│ └── slack_client.py
├── helpers
│ ├── __init__.py
│ ├── __pycache__
│ └── math_helpers.py
├── models
│ ├── __init__.py
│ ├── __pycache__
│ ├── pair.py
├── requirements.txt
├── tests
│ ├── __init__.py
│ ├── __pycache__
│ └── test_pair.py
When I run this test in the tests
folder:
from models.pair import Pair
def test_name():
coin = "some_coin"
underlying_asset = "BTC"
pair = Pair(coin, underlying_asset)
print(pair)
I get an error.
ImportError while importing test module '/Users/stride-admin/kittycapital/tests/test_pair.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_pair.py:1: in <module>
from models.pair import Pair
E ModuleNotFoundError: No module named 'models'
=========================================================================================================================== short test summary info ============================================================================================================================
ERROR tests/test_pair.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
In the root directory (same level as clients
, tests
, models
) when I run pytest I get the above error. What am I doing wrong?
When I do this in my test file:
from ..models.pair import Pair
def test_name():
coin = "some_coin"
underlying_asset = "BTC"
pair = Pair(coin, underlying_asset)
print(pair)
I get this error:
ImportError while importing test module '/Users/stride-admin/kittycapital/tests/test_pair.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_pair.py:1: in <module>
from ..models.pair import Pair
models/pair.py:1: in <module>
from clients.binance_client import BinanceClient, BinanceAPIError
E ModuleNotFoundError: No module named 'clients'
So that feels wrong.