Commit c5e598a8 by Timothée Peignier

improve test runner

parent 7465391d
......@@ -10,5 +10,6 @@ docs/_build/
*.egg-info
.coverage
coverage/
tests/static/js/dummy.js
.tox/
\ No newline at end of file
tests/assets/js/dummy.js
.tox/
.DS_Store
\ No newline at end of file
#!/usr/bin/env python
import coverage
import os
import sys
from django.conf import settings
TEST_DIR = os.path.dirname(os.path.abspath(__file__))
if not settings.configured:
settings.configure(
PIPELINE_CACHE_BACKEND='dummy://',
DATABASE_ENGINE='sqlite3',
INSTALLED_APPS=[
'pipeline',
'tests'
],
MEDIA_URL='/media/',
MEDIA_ROOT=os.path.join(TEST_DIR, 'media'),
STATIC_URL='/static/',
STATIC_ROOT=os.path.join(TEST_DIR, 'static'),
TEMPLATE_DIRS=(
os.path.join(TEST_DIR, 'templates'),
),
TEST_DIR=TEST_DIR,
)
from django.test.simple import run_tests
def runtests(*test_args):
if not test_args:
test_args = ['tests']
parent_dir = os.path.join(TEST_DIR, "../")
sys.path.insert(0, parent_dir)
cover = coverage.coverage(branch=True, cover_pylib=False,
include=[
os.path.join(parent_dir, 'pipeline', '*.py')
],
omit=[
os.path.join(parent_dir, 'tests', '*.py'),
os.path.join(parent_dir, 'pipeline', 'compressors',
'jsmin', 'jsmin.py'),
]
)
cover.load()
cover.start()
failures = run_tests(test_args, verbosity=1, interactive=True)
cover.stop()
cover.save()
cover.report(file=sys.stdout)
sys.exit(failures)
if __name__ == '__main__':
runtests(*sys.argv[1:])
import os
import os
local_path = lambda path: os.path.join(os.path.dirname(__file__), path)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'TEST_NAME': ':memory:'
}
}
INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.sites',
'django.contrib.auth',
'django.contrib.admin',
'pipeline',
'tests',
]
MEDIA_URL = '/media/'
MEDIA_ROOT = local_path('media')
STATIC_URL = '/static/'
STATIC_ROOT = local_path('assets')
TEMPLATE_DIRS = (
local_path('templates'),
)
......@@ -4,12 +4,11 @@ downloadcache = .tox/_download/
[testenv]
setenv =
PYTHONPATH = {toxinidir}/tests
PYTHONPATH = {toxinidir}
commands =
python {toxinidir}/tests/runtests.py
{envbindir}/django-admin.py test {posargs:tests} --settings=tests.settings
deps =
django==1.3
coverage>=3.4
mock>=0.7.2
[testenv:docs]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment