3๐
โ
So I ended up solving my own issue. As @hoefling mentioned, the best way is to create a separate settings file that extends your normal settings file and specify that as your pytest settings file.
// pytest.ini
[pytest]
addopts = --ds=config.settings.test
An important thing to note is that you cannot have your test modules be the same name as already existing apps, as I found out. So the structure I had with backend/tests/richeditable is not allowed no matter what you do. So I prepended each folder with test_
and it works fine. This also solves the issue of having to include app_label
in your models.
# testsettings.py
from .settings import * # noqa
INSTALLED_APPS += [
'backend.tests.test_projects',
'backend.tests.test_blog',
'backend.tests.test_richeditable',
]
backend
โโโ projects
โโโ blog
โโโ richeditable
โโโ tests
โ โโโ __init__.py
โ โโโ conftest.py
โ โโโ test_blog
โ โ โโโ ...
โ โโโ test_projects
โ โ โโโ ...
โ โโโ test_richeditable
โ โ โโโ __init__.py
โ โ โโโ test_model.py
โ โ โโโ models.py
๐คKalin Kochnev
Source:stackexchange.com