From 59f00611da0377f434c26bfa66c110b46cc030ba Mon Sep 17 00:00:00 2001 From: SKairinos Date: Thu, 28 Sep 2023 16:44:17 +0100 Subject: [PATCH] get pytest working --- .vscode/settings.json | 7 ++++++- Pipfile | 1 + Pipfile.lock | 14 +++++++++++--- manage.py | 9 +++++++++ pyproject.toml | 4 +--- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9b388533..962594af 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,11 @@ { + "black-formatter.args": [ + "--config", + "pyproject.toml" + ], "python.testing.pytestArgs": [ - "tests" + "-c=pyproject.toml", + "." ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true diff --git a/Pipfile b/Pipfile index 9562e504..13d9a95f 100644 --- a/Pipfile +++ b/Pipfile @@ -29,6 +29,7 @@ pytest-django = "==4.5.2" django-extensions = "==3.2.1" pyparsing = "==3.0.9" pydot = "==1.4.2" +pytest-env = "==0.8.1" [requires] python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock index feed9c97..c43f6514 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "4ee0d319733af37f4930e56cf41ae943be49e1e03fc358c412fc4349ab6102a6" + "sha256": "aa3e3eedfa674929a89e7496ab35a21a63986025b3ade8f19b29004d0afffda4" }, "pipfile-spec": 6, "requires": { @@ -815,7 +815,7 @@ "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86", "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.8.2" }, "pytz": { @@ -964,7 +964,7 @@ "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==1.16.0" }, "sortedcontainers": { @@ -1220,6 +1220,14 @@ "index": "pypi", "version": "==4.5.2" }, + "pytest-env": { + "hashes": [ + "sha256:8c0605ae09a5b7e41c20ebcc44f2c906eea9654095b4b0c342b3814bcc3a8492", + "sha256:d7b2f5273ec6d1e221757998bc2f50d2474ed7d0b9331b92556011fadc4e9abf" + ], + "index": "pypi", + "version": "==0.8.1" + }, "pytz": { "hashes": [ "sha256:7b4fddbeb94a1eba4b557da24f19fdf9db575192544270a9101d8509f9f43d7b", diff --git a/manage.py b/manage.py index 020259c4..a317e0a8 100644 --- a/manage.py +++ b/manage.py @@ -2,6 +2,8 @@ from codeforlife.settings import * +BASE_DIR = Path(__file__).resolve().parent + INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", @@ -41,6 +43,13 @@ }, ] +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } +} + if __name__ == "__main__": import os import sys diff --git a/pyproject.toml b/pyproject.toml index 6a1b96d6..17a1a0d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,4 @@ line-length = 80 extend-exclude = "^/setup.py|^/codeforlife/user/migrations/" [tool.pytest.ini_options] -# env = ["DJANGO_SETTINGS_MODULE=example_project.settings"] -DJANGO_SETTINGS_MODULE = "manage" -python_files = "tests.py test_*.py" +env = ["DJANGO_SETTINGS_MODULE=manage"]