Begin to split tests, Makefile less phony, use py.test
This commit is contained in:
parent
33f53f1d25
commit
abda112467
@ -1,3 +1,8 @@
|
|||||||
|
[run]
|
||||||
|
branch = True
|
||||||
|
source = cas_server
|
||||||
|
omit = cas_server/migrations*
|
||||||
|
|
||||||
[report]
|
[report]
|
||||||
exclude_lines =
|
exclude_lines =
|
||||||
pragma: no cover
|
pragma: no cover
|
||||||
|
26
Makefile
26
Makefile
@ -1,4 +1,4 @@
|
|||||||
.PHONY: clean build install dist test_venv test_project
|
.PHONY: build dist
|
||||||
VERSION=`python setup.py -V`
|
VERSION=`python setup.py -V`
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@ -16,18 +16,19 @@ clean_tox:
|
|||||||
rm -rf .tox
|
rm -rf .tox
|
||||||
clean_test_venv:
|
clean_test_venv:
|
||||||
rm -rf test_venv
|
rm -rf test_venv
|
||||||
|
|
||||||
clean: clean_pyc clean_build
|
clean: clean_pyc clean_build
|
||||||
|
|
||||||
clean_all: clean_pyc clean_build clean_tox clean_test_venv
|
clean_all: clean_pyc clean_build clean_tox clean_test_venv
|
||||||
|
|
||||||
dist:
|
dist:
|
||||||
python setup.py sdist
|
python setup.py sdist
|
||||||
|
|
||||||
test_venv:
|
test_venv/bin/python:
|
||||||
mkdir -p test_venv
|
|
||||||
virtualenv test_venv
|
virtualenv test_venv
|
||||||
test_venv/bin/pip install -U --requirement requirements.txt
|
test_venv/bin/pip install -U --requirement requirements-dev.txt Django
|
||||||
|
|
||||||
test_venv/cas/manage.py:
|
test_venv/cas/manage.py: test_venv
|
||||||
mkdir -p test_venv/cas
|
mkdir -p test_venv/cas
|
||||||
test_venv/bin/django-admin startproject cas test_venv/cas
|
test_venv/bin/django-admin startproject cas test_venv/cas
|
||||||
ln -s ../../cas_server test_venv/cas/cas_server
|
ln -s ../../cas_server test_venv/cas/cas_server
|
||||||
@ -38,16 +39,23 @@ test_venv/cas/manage.py:
|
|||||||
test_venv/bin/python test_venv/cas/manage.py migrate
|
test_venv/bin/python test_venv/cas/manage.py migrate
|
||||||
test_venv/bin/python test_venv/cas/manage.py createsuperuser
|
test_venv/bin/python test_venv/cas/manage.py createsuperuser
|
||||||
|
|
||||||
test_project: test_venv test_venv/cas/manage.py
|
test_venv/bin/coverage: test_venv
|
||||||
|
test_venv/bin/pip install coverage
|
||||||
|
|
||||||
|
test_venv: test_venv/bin/python
|
||||||
|
|
||||||
|
test_project: test_venv/cas/manage.py
|
||||||
@echo "##############################################################"
|
@echo "##############################################################"
|
||||||
@echo "A test django project was created in $(realpath test_venv/cas)"
|
@echo "A test django project was created in $(realpath test_venv/cas)"
|
||||||
|
|
||||||
run_test_server: test_project
|
run_test_server: test_project
|
||||||
test_venv/bin/python test_venv/cas/manage.py runserver
|
test_venv/bin/python test_venv/cas/manage.py runserver
|
||||||
|
|
||||||
coverage: test_venv
|
tests: test_venv
|
||||||
test_venv/bin/pip install coverage
|
test_venv/bin/py.test
|
||||||
test_venv/bin/coverage run --source='cas_server' --omit='cas_server/migrations*' run_tests
|
|
||||||
|
coverage: test_venv/bin/coverage
|
||||||
|
test_venv/bin/coverage run test_venv/bin/py.test
|
||||||
test_venv/bin/coverage html
|
test_venv/bin/coverage html
|
||||||
rm htmlcov/coverage_html.js # I am really pissed off by those keybord shortcuts
|
rm htmlcov/coverage_html.js # I am really pissed off by those keybord shortcuts
|
||||||
|
|
||||||
|
0
cas_server/tests/__init__.py
Normal file
0
cas_server/tests/__init__.py
Normal file
@ -52,7 +52,7 @@ MIDDLEWARE_CLASSES = [
|
|||||||
'django.middleware.locale.LocaleMiddleware',
|
'django.middleware.locale.LocaleMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'urls_tests'
|
ROOT_URLCONF = 'cas_server.tests.urls'
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
|
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
|
||||||
@ -60,6 +60,7 @@ ROOT_URLCONF = 'urls_tests'
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
|
'NAME': ':memory:',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
"""Tests module"""
|
"""Tests module"""
|
||||||
from .default_settings import settings
|
from cas_server.default_settings import settings
|
||||||
|
|
||||||
import django
|
import django
|
||||||
from django.test import TestCase, Client
|
from django.test import TestCase, Client
|
5
pytest.ini
Normal file
5
pytest.ini
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[pytest]
|
||||||
|
testpaths = cas_server/tests/
|
||||||
|
DJANGO_SETTINGS_MODULE = cas_server.tests.settings
|
||||||
|
norecursedirs = .* build dist docs
|
||||||
|
python_paths = .
|
@ -1,10 +1,11 @@
|
|||||||
tox==1.8.1
|
setuptools>=5.5
|
||||||
pytest==2.6.4
|
tox>=1.8.1
|
||||||
pytest-django==2.7.0
|
pytest>=2.6.4
|
||||||
pytest-pythonpath==0.3
|
pytest-django>=2.8.0
|
||||||
|
pytest-pythonpath>=0.3
|
||||||
requests>=2.4
|
requests>=2.4
|
||||||
django-picklefield>=0.3.1
|
|
||||||
requests_futures>=0.9.5
|
requests_futures>=0.9.5
|
||||||
|
django-picklefield>=0.3.1
|
||||||
django-bootstrap3>=5.4
|
django-bootstrap3>=5.4
|
||||||
lxml>=3.4
|
lxml>=3.4
|
||||||
six>=1
|
six>=1
|
||||||
|
22
run_tests
22
run_tests
@ -1,22 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
import os, sys
|
|
||||||
import django
|
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
import settings_tests
|
|
||||||
|
|
||||||
settings.configure(**settings_tests.__dict__)
|
|
||||||
django.setup()
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Django <= 1.8
|
|
||||||
from django.test.simple import DjangoTestSuiteRunner
|
|
||||||
test_runner = DjangoTestSuiteRunner(verbosity=1)
|
|
||||||
except ImportError:
|
|
||||||
# Django >= 1.8
|
|
||||||
from django.test.runner import DiscoverRunner
|
|
||||||
test_runner = DiscoverRunner(verbosity=1)
|
|
||||||
|
|
||||||
failures = test_runner.run_tests(['cas_server'])
|
|
||||||
if failures:
|
|
||||||
sys.exit(failures)
|
|
3
setup.py
3
setup.py
@ -34,7 +34,8 @@ setup(
|
|||||||
version='0.4.4',
|
version='0.4.4',
|
||||||
packages=[
|
packages=[
|
||||||
'cas_server', 'cas_server.migrations',
|
'cas_server', 'cas_server.migrations',
|
||||||
'cas_server.management', 'cas_server.management.commands'
|
'cas_server.management', 'cas_server.management.commands',
|
||||||
|
'cas_server.tests'
|
||||||
],
|
],
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
license='GPLv3',
|
license='GPLv3',
|
||||||
|
2
tox.ini
2
tox.ini
@ -17,7 +17,7 @@ deps =
|
|||||||
-r{toxinidir}/requirements-dev.txt
|
-r{toxinidir}/requirements-dev.txt
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
commands=python run_tests {posargs:tests}
|
commands=py.test {posargs:cas_server/tests/}
|
||||||
|
|
||||||
[testenv:py27-django17]
|
[testenv:py27-django17]
|
||||||
basepython=python2.7
|
basepython=python2.7
|
||||||
|
Loading…
Reference in New Issue
Block a user