Skip to content

Commit

Permalink
Run tests with pytest instead of nose
Browse files Browse the repository at this point in the history
  • Loading branch information
David Glick committed Mar 13, 2019
1 parent 25a2c65 commit 2433c5d
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 23 deletions.
2 changes: 0 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[run]
include = metaci/*
omit = *migrations*, *tests*
plugins =
django_coverage_plugin
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ npm-debug.log*
# Unit test / coverage reports
.coverage
.tox
nosetests.xml
htmlcov
*.tap

# Translations
*.mo
Expand Down
9 changes: 9 additions & 0 deletions config/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
11 changes: 3 additions & 8 deletions config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
# ------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion heroku_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion metaci/api/tests.py
Original file line number Diff line number Diff line change
@@ -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."""

Expand Down
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[pytest]
DJANGO_SETTINGS_MODULE=config.settings.local
DJANGO_SETTINGS_MODULE=config.settings.test
python_files = test*.py
3 changes: 0 additions & 3 deletions requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ django-debug-toolbar==1.11

# improved REPL
ipdb==0.11

pytest-django==3.4.8
# pytest-sugar==0.9.2
9 changes: 3 additions & 6 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2433c5d

Please sign in to comment.