From 0b8a9cf1a65dae88a55a58c9b9b1a878d90daaaa Mon Sep 17 00:00:00 2001 From: Jim Fingal Date: Sun, 8 Nov 2020 12:14:57 -0800 Subject: [PATCH] Add support for pytest --- .coveragerc | 2 ++ docker-compose.yml | 1 + fr-dev | 9 ++++++++- pytest.ini | 4 ++++ requirements.txt | 3 +++ 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .coveragerc create mode 100644 pytest.ini diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..35bf78f5f --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +omit = */test*,celerywyrm*,bookwyrm/migrations/* \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 18b58032c..08567ce33 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,6 +22,7 @@ services: - main web: build: . + env_file: .env command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/app diff --git a/fr-dev b/fr-dev index b9502b663..39c8b1839 100755 --- a/fr-dev +++ b/fr-dev @@ -46,6 +46,9 @@ case "$1" in migrate) runweb python manage.py migrate ;; + bash) + runweb bash + ;; shell) runweb python manage.py shell ;; @@ -59,6 +62,10 @@ case "$1" in shift 1 runweb coverage run --source='.' --omit="*/test*,celerywyrm*,bookwyrm/migrations/*" manage.py test "$@" ;; + pytest) + shift 1 + runweb pytest "$@" + ;; test_report) runweb coverage report ;; @@ -72,6 +79,6 @@ case "$1" in clean ;; *) - echo "Unrecognised command. Try: build, clean, up, initdb, resetdb, makemigrations, migrate, shell, dbshell, restart_celery, test, test_report" + echo "Unrecognised command. Try: build, clean, up, initdb, resetdb, makemigrations, migrate, bash, shell, dbshell, restart_celery, test, pytest, test_report" ;; esac diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..c6a261d6c --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +DJANGO_SETTINGS_MODULE = bookwyrm.settings +python_files = tests.py test_*.py *_tests.py +addopts = --cov=bookwyrm --cov-config=.coveragerc \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index e041ec25d..ff5848d56 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,9 @@ Pillow>=7.1.0 psycopg2==2.8.4 pycryptodome==3.9.4 python-dateutil==2.8.1 +pytest_django==4.1.0 +pytest==6.1.2 +pytest-cov==2.10.1 redis==3.4.1 requests==2.22.0 responses==0.10.14