diff options
Diffstat (limited to 'wkhtmltopdf/tests/run.py')
-rw-r--r-- | wkhtmltopdf/tests/run.py | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/wkhtmltopdf/tests/run.py b/wkhtmltopdf/tests/run.py index 5004ee1..b969a29 100644 --- a/wkhtmltopdf/tests/run.py +++ b/wkhtmltopdf/tests/run.py @@ -9,6 +9,26 @@ DIRNAME = os.path.abspath(os.path.dirname(__file__)) sys.path.insert(0, os.getcwd()) +def run_tests(): + # Utility function to executes tests. + # Will be called twice. Once with DEBUG=True and once with DEBUG=False. + try: + django.setup() + except AttributeError: + pass # Django < 1.7; okay to ignore + + + try: + from django.test.runner import DiscoverRunner + except ImportError: + from discover_runner.runner import DiscoverRunner + + + test_runner = DiscoverRunner(verbosity=1) + failures = test_runner.run_tests(['wkhtmltopdf']) + if failures: + sys.exit(1) + settings.configure( DEBUG=True, DATABASES={ @@ -32,19 +52,11 @@ settings.configure( WKHTMLTOPDF_DEBUG=True, ) -try: - django.setup() -except AttributeError: - pass # Django < 1.7; okay to ignore - - -try: - from django.test.runner import DiscoverRunner -except ImportError: - from discover_runner.runner import DiscoverRunner +# Run tests with True debug settings (persistent temporary files). +run_tests() +settings.DEBUG = False +settings.WKHTMLTOPDF_DEBUG = False -test_runner = DiscoverRunner(verbosity=1) -failures = test_runner.run_tests(['wkhtmltopdf']) -if failures: - sys.exit(1) +# Run tests with False debug settings to test temporary file delete operations. +run_tests() |