From 3898e56c1f8a4cceea21e2628fdb7d93f97ca615 Mon Sep 17 00:00:00 2001 From: Matt Lenc Date: Wed, 18 Jun 2014 12:27:54 +0100 Subject: Make teh tests run right Because Django 1.6 and other fireworks. --- .travis.yml | 1 + Makefile | 9 +++++++-- run_tests.sh | 6 ------ test_requirements.txt | 2 ++ wkhtmltopdf/test_settings.py | 30 ------------------------------ wkhtmltopdf/tests/run.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 38 deletions(-) delete mode 100755 run_tests.sh create mode 100644 test_requirements.txt delete mode 100644 wkhtmltopdf/test_settings.py create mode 100644 wkhtmltopdf/tests/run.py diff --git a/.travis.yml b/.travis.yml index 0cbb0de..a7f43c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ before_script: - "./before_script.sh" install: - pip install $DJANGO + - pip install -r test_requirements.txt - pip install . script: - make test diff --git a/Makefile b/Makefile index 059771c..eb99a79 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,12 @@ SHELL := /bin/bash +help: + @echo "Usage:" + @echo " make release | Release to pypi." + @echo " make test | Run the tests." + release: - python setup.py register sdist upload + python setup.py register sdist bdist_wheel upload test: - ./run_tests.sh + python ./wkhtmltopdf/tests/run.py diff --git a/run_tests.sh b/run_tests.sh deleted file mode 100755 index 1cb1dd5..0000000 --- a/run_tests.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -export WKHTMLTOPDF_CMD=`pwd`/wkhtmltox_folder/wkhtmltox/bin/wkhtmltopdf; -export PYTHONPATH=.:$$PYTHONPATH; - -django-admin.py test tests --settings=wkhtmltopdf.test_settings diff --git a/test_requirements.txt b/test_requirements.txt new file mode 100644 index 0000000..ba357b3 --- /dev/null +++ b/test_requirements.txt @@ -0,0 +1,2 @@ +colour-runner==0.0.4 +django-discover-runner==1.0 diff --git a/wkhtmltopdf/test_settings.py b/wkhtmltopdf/test_settings.py deleted file mode 100644 index 16fb734..0000000 --- a/wkhtmltopdf/test_settings.py +++ /dev/null @@ -1,30 +0,0 @@ -import os - -DEBUG = True - -DIRNAME = os.path.abspath(os.path.dirname(__file__)) - -SECRET_KEY = 'fooooooo' - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': ':memory:', - } -} - -MEDIA_ROOT = os.path.join(DIRNAME, 'media') -MEDIA_URL = '/media/' -STATIC_ROOT = os.path.join(DIRNAME, 'static') -STATIC_URL = '/static/' - -INSTALLED_APPS = ( - 'wkhtmltopdf.tests', - 'wkhtmltopdf', -) - -TEMPLATE_DIRS = [ - os.path.join(DIRNAME, 'testproject', 'tests', 'templates'), -] - -WKHTMLTOPDF_DEBUG = DEBUG diff --git a/wkhtmltopdf/tests/run.py b/wkhtmltopdf/tests/run.py new file mode 100644 index 0000000..239f5dc --- /dev/null +++ b/wkhtmltopdf/tests/run.py @@ -0,0 +1,43 @@ +#! /usr/bin/env python +import os +import sys + +from colour_runner.django_runner import ColourRunnerMixin +from django.conf import settings + +DIRNAME = os.path.abspath(os.path.dirname(__file__)) + + +settings.configure( + DEBUG=True, + DATABASES={ + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': ':memory:', + } + }, + INSTALLED_APPS=( + 'wkhtmltopdf.tests', + 'wkhtmltopdf', + ), + MEDIA_ROOT=os.path.join(DIRNAME, 'media'), + MEDIA_URL='/media/', + STATIC_ROOT=os.path.join(DIRNAME, 'static'), + STATIC_URL='/static/', + WKHTMLTOPDF_DEBUG=True, +) + +try: + from django.test.runner import DiscoverRunner +except ImportError: + from discover_runner.runner import DiscoverRunner + + +class TestRunner(ColourRunnerMixin, DiscoverRunner): + pass + + +test_runner = TestRunner(verbosity=1) +failures = test_runner.run_tests(['wkhtmltopdf']) +if failures: + sys.exit(1) -- cgit v1.2.3