From 75f939164c17c63002f60baa84b13a486470950c Mon Sep 17 00:00:00 2001 From: Eliot Berriot <contact@eliotberriot.com> Date: Sat, 25 May 2019 14:17:37 +0200 Subject: [PATCH] Basic test setup --- config/settings/base.py | 2 +- pytest.ini | 2 -- retribute_api/conftest.py | 20 -------------------- setup.cfg | 9 ++++++++- tests/conftest.py | 0 tests/test_dummy.py | 2 ++ 6 files changed, 11 insertions(+), 24 deletions(-) delete mode 100644 pytest.ini delete mode 100644 retribute_api/conftest.py create mode 100644 tests/conftest.py create mode 100644 tests/test_dummy.py diff --git a/config/settings/base.py b/config/settings/base.py index 502a84f..2aa5241 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -14,7 +14,7 @@ env = environ.Env() READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=True) if READ_DOT_ENV_FILE: # OS environment variables take precedence over variables from .env - env.read_env(str(ROOT_DIR.path(".env"))) + env.read_env(env.bool("DJANGO_DOT_ENV_FILE", default=str(ROOT_DIR.path(".env")))) # GENERAL # ------------------------------------------------------------------------------ diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 5b4369b..0000000 --- a/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -DJANGO_SETTINGS_MODULE=config.settings.test diff --git a/retribute_api/conftest.py b/retribute_api/conftest.py deleted file mode 100644 index 7c439aa..0000000 --- a/retribute_api/conftest.py +++ /dev/null @@ -1,20 +0,0 @@ -import pytest -from django.conf import settings -from django.test import RequestFactory - -from retribute_api.users.tests.factories import UserFactory - - -@pytest.fixture(autouse=True) -def media_storage(settings, tmpdir): - settings.MEDIA_ROOT = tmpdir.strpath - - -@pytest.fixture -def user() -> settings.AUTH_USER_MODEL: - return UserFactory() - - -@pytest.fixture -def request_factory() -> RequestFactory: - return RequestFactory() diff --git a/setup.cfg b/setup.cfg index baf7b74..9d1f12b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -46,13 +46,13 @@ dev = pytest-mock pytest-env pytest-sugar + pytest-django flake8 coverage black pylint-django factory-boy django-debug-toolbar - pytest-django [options.packages.find] @@ -64,6 +64,13 @@ universal = 1 [tool:pytest] testpaths = tests +env = + SECRET_KEY=test + EMAIL_CONFIG=consolemail:// + DEBUG_TOOLBAR_ENABLED=False + DEBUG=False + WEAK_PASSWORDS=True + [flake8] max-line-length = 120 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_dummy.py b/tests/test_dummy.py new file mode 100644 index 0000000..482b664 --- /dev/null +++ b/tests/test_dummy.py @@ -0,0 +1,2 @@ +def test_something(): + assert 1 == 2 -- GitLab