Skip to content

Commit

Permalink
Switch to py.test
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankoegl committed Nov 26, 2017
1 parent 41128ac commit c922e38
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ envs

# Jupyter Notebooks
notebooks/

.cache
File renamed without changes.
9 changes: 9 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest


@pytest.fixture(autouse=True)
def enable_db_access_for_all_tests(db):
""" Enable DB access for all tests
http://pytest-django.readthedocs.io/en/latest/faq.html#how-can-i-give-database-access-to-all-my-tests-without-the-django-db-marker """
pass
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ help:
@echo 'make clean clean up files'

test:
envdir envs/dev/ python -Wd -m coverage run ./manage.py test
coverage report
envdir envs/dev/ pytest --cov=mygpo/ --cov-branch
coverage report --show-missing

update-po:
envdir envs/dev/ python manage.py makemessages \
Expand Down
9 changes: 0 additions & 9 deletions mygpo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ def get_intOrNone(name, default):
'mygpo.pubsub',
'mygpo.podcastlists',
'mygpo.votes',
'django_nose',
]

try:
Expand Down Expand Up @@ -373,13 +372,5 @@ def get_intOrNone(name, default):

PODCAST_AD_ID = os.getenv('PODCAST_AD_ID')

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

NOSE_ARGS = [
'--with-doctest',
'--stop',
'--where=mygpo',
]


SEARCH_CUTOFF = float(os.getenv('SEARCH_CUTOFF', 0.3))
4 changes: 2 additions & 2 deletions mygpo/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections import Counter

from django.urls import reverse
from django.test.client import Client as TestClient
from django.test.client import Client as TClient
from django.test import TestCase
from django.test.utils import override_settings
from django.contrib.auth import get_user_model
Expand Down Expand Up @@ -100,7 +100,7 @@ class AuthTests(TestCase):

def setUp(self):
self.user, pwd = create_user()
self.client = TestClient()
self.client = TClient()
wrong_pwd = pwd + '1234'
self.extra = {
'HTTP_AUTHORIZATION': create_auth_string(self.user.username,
Expand Down
4 changes: 2 additions & 2 deletions mygpo/usersettings/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json

from django.urls import reverse
from django.test.client import Client as TestClient
from django.test.client import Client as TClient
from django.test import TestCase

from mygpo.test import create_auth_string, create_user
Expand All @@ -32,7 +32,7 @@ def setUp(self):
user = self.user,
uid = self.uid,
)
self.client = TestClient()
self.client = TClient()
self.extra = {
'HTTP_AUTHORIZATION': create_auth_string(self.user.username, pwd)
}
Expand Down
5 changes: 5 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pytest]
DJANGO_SETTINGS_MODULE = mygpo.settings
python_files = tests.py test_*.py *_tests.py
addopts = --doctest-modules
norecursedirs = tools conf
4 changes: 2 additions & 2 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
coverage==4.4.1
django-coverage-plugin==1.5.0
django-nose==1.4.5
nose==1.3.7
pytest-django
pytest-cov
responses==0.8.1

0 comments on commit c922e38

Please sign in to comment.