switch to py.test + pytest-cov

This commit is contained in:
Tony Narlock 2017-12-11 08:08:47 -06:00
parent 6dd7556da7
commit 28bd4567a7
6 changed files with 22 additions and 44 deletions

View file

@ -55,6 +55,6 @@ install:
- if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then export PYVER=py35; fi
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then export PYVER=py36; fi
script: COMMAND='coverage run' tox -e$TOXENV
script: tox -e$TOXENV -- --cov # positional args ({posargs}) to pass into tox.ini
after_success: codecov

2
requirements-test.txt Normal file
View file

@ -0,0 +1,2 @@
pytest==3.3.1
pytest-django==3.1.2

View file

@ -1,41 +0,0 @@
#!/usr/bin/env python
import os, sys
from django.conf import settings
import django
DEFAULT_SETTINGS = dict(
INSTALLED_APPS=(
'model_utils',
'tests',
),
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3"
}
},
SILENCED_SYSTEM_CHECKS=["1_7.W001"],
)
def runtests():
if not settings.configured:
settings.configure(**DEFAULT_SETTINGS)
django.setup()
parent = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, parent)
from django.test.runner import DiscoverRunner
runner_class = DiscoverRunner
test_args = ['tests']
failures = runner_class(
verbosity=1, interactive=True, failfast=False).run_tests(test_args)
sys.exit(failures)
if __name__ == '__main__':
runtests()

View file

@ -3,5 +3,9 @@ source-dir = docs/
build-dir = docs/_build
all_files = 1
[tool:pytest]
django_find_project = false
DJANGO_SETTINGS_MODULE = tests.settings
[wheel]
universal = 1

10
tests/settings.py Normal file
View file

@ -0,0 +1,10 @@
INSTALLED_APPS = (
'model_utils',
'tests',
)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3'
}
}
SECRET_KEY = 'dummy'

View file

@ -7,7 +7,6 @@ envlist =
[testenv]
deps =
coverage == 3.6
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
@ -15,5 +14,9 @@ deps =
django200: Django>=2.0,<2.1
djangotrunk: https://github.com/django/django/tarball/master
freezegun == 0.3.8
-rrequirements-test.txt
pytest-cov
commands = {env:COMMAND:python} runtests.py
commands =
pip install -e .
py.test {posargs}