From 2433c5d2579fdab20603124e55c26cf88c98b697 Mon Sep 17 00:00:00 2001 From: David Glick Date: Wed, 13 Mar 2019 15:55:28 -0400 Subject: [PATCH] Run tests with pytest instead of nose --- .coveragerc | 2 -- .gitignore | 2 +- config/settings/common.py | 9 +++++++++ config/settings/test.py | 11 +++-------- heroku_ci.sh | 2 +- metaci/api/tests.py | 1 - pytest.ini | 3 ++- requirements/local.txt | 3 --- requirements/test.txt | 9 +++------ 9 files changed, 19 insertions(+), 23 deletions(-) diff --git a/.coveragerc b/.coveragerc index 5c4303a72..1bc7a8b7e 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,5 +1,3 @@ [run] include = metaci/* omit = *migrations*, *tests* -plugins = - django_coverage_plugin diff --git a/.gitignore b/.gitignore index a2c832d1f..9b9e52ee5 100644 --- a/.gitignore +++ b/.gitignore @@ -35,8 +35,8 @@ npm-debug.log* # Unit test / coverage reports .coverage .tox -nosetests.xml htmlcov +*.tap # Translations *.mo diff --git a/config/settings/common.py b/config/settings/common.py index ce90e13aa..a93e957df 100644 --- a/config/settings/common.py +++ b/config/settings/common.py @@ -85,6 +85,15 @@ def url_prefix_list(val: str) -> List[str]: # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS +ALLOWED_HOSTS = [ + "127.0.0.1", + "127.0.0.1:8000", + "127.0.0.1:8080", + "localhost", + "localhost:8000", + "localhost:8080", +] + # MIDDLEWARE CONFIGURATION # ------------------------------------------------------------------------------ MIDDLEWARE = ( diff --git a/config/settings/test.py b/config/settings/test.py index 2940af181..635e971c7 100644 --- a/config/settings/test.py +++ b/config/settings/test.py @@ -14,6 +14,9 @@ DEBUG = False TEMPLATES[0]["OPTIONS"]["debug"] = False +# Allow requests with Host: testserver +ALLOWED_HOSTS = ['testserver'] + # SECRET CONFIGURATION # ------------------------------------------------------------------------------ # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key @@ -45,14 +48,6 @@ "short": {"URL": REDIS_URL, "DEFAULT_TIMEOUT": 500, "AUTOCOMMIT": False}, } -# Add django_nose to INSTALLED_APPS -INSTALLED_APPS = INSTALLED_APPS + ("django_nose",) - -# TESTING -# ------------------------------------------------------------------------------ -TEST_RUNNER = "django_nose.NoseTestSuiteRunner" -NOSE_ARGS = ["--with-tap", "--tap-stream", "--with-coverage", "--cover-package=metaci"] - # PASSWORD HASHING # ------------------------------------------------------------------------------ diff --git a/heroku_ci.sh b/heroku_ci.sh index 886c81003..fca2c6af7 100755 --- a/heroku_ci.sh +++ b/heroku_ci.sh @@ -5,7 +5,7 @@ git clone -b "$HEROKU_TEST_RUN_BRANCH" --single-branch https://github.com/SFDO-T cd MetaCI_checkout git reset --hard $HEROKU_TEST_RUN_COMMIT_VERSION export DJANGO_SETTINGS_MODULE=config.settings.test -python manage.py test +coverage run $(which pytest) --tap-stream exit_status=$? coveralls if [ "$exit_status" != "0" ]; then diff --git a/metaci/api/tests.py b/metaci/api/tests.py index 79c48eb41..ed4562639 100644 --- a/metaci/api/tests.py +++ b/metaci/api/tests.py @@ -1,7 +1,6 @@ from rest_framework.reverse import reverse from test_plus.test import TestCase - class TestURLReversals(TestCase): """Test URL patterns for APIs app.""" diff --git a/pytest.ini b/pytest.ini index d19d28c54..f5c0321f9 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,3 @@ [pytest] -DJANGO_SETTINGS_MODULE=config.settings.local +DJANGO_SETTINGS_MODULE=config.settings.test +python_files = test*.py diff --git a/requirements/local.txt b/requirements/local.txt index 48911e096..9ec5f2ba9 100644 --- a/requirements/local.txt +++ b/requirements/local.txt @@ -12,6 +12,3 @@ django-debug-toolbar==1.11 # improved REPL ipdb==0.11 - -pytest-django==3.4.8 -# pytest-sugar==0.9.2 diff --git a/requirements/test.txt b/requirements/test.txt index bd0afba8b..735532b53 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -2,13 +2,10 @@ -r base.txt pytest==4.3.0 +pytest-django==3.4.8 +pytest-tap==2.3 coverage==4.5.3 -django_coverage_plugin==1.6.0 +coveralls==1.6.0 flake8==3.7.7 django-test-plus==1.1.1 factory_boy==2.11.1 - -# nosetests with support for TAP and coveralls -django_nose==1.4.6 -nose-tap==1.9 -coveralls==1.6.0