use pytest for testing

This commit is contained in:
Gonçalo Valério 2019-10-15 18:13:56 +01:00
parent 6da3033fdf
commit 34928676c6
4 changed files with 7 additions and 28 deletions

3
pytest.ini Normal file
View File

@ -0,0 +1,3 @@
[pytest]
DJANGO_SETTINGS_MODULE = tests.settings
python_files = tests.py test_*.py *_tests.py

View File

@ -5,3 +5,6 @@ mock>=1.0.1
flake8>=2.1.0
tox>=1.7.0
coveralls
pytest
pytest-django
pytest-cov

View File

@ -1,26 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8
from __future__ import unicode_literals, absolute_import
import os
import sys
import django
from django.conf import settings
from django.test.utils import get_runner
def run_tests(*test_args):
if not test_args:
test_args = ["tests"]
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(test_args)
sys.exit(bool(failures))
if __name__ == "__main__":
run_tests(*sys.argv[1:])

View File

@ -5,9 +5,8 @@ envlist =
[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/django_cryptolock
commands = coverage run --source django_cryptolock runtests.py
commands = pytest --cov=django_cryptolock tests/
deps =
django-22: Django>=2.2
-r {toxinidir}/requirements_test.txt
basepython =
py37: python3.7