aboutsummaryrefslogtreecommitdiffstats
path: root/wkhtmltopdf/tests
diff options
context:
space:
mode:
authorJosh <josh@halfnibble.com>2016-02-26 16:24:09 -0800
committerJosh <josh@halfnibble.com>2016-02-26 16:24:09 -0800
commitd7bb07ad4468d738f5ba321ee730921f3886e5a3 (patch)
tree54a1b50038837cf483066fa08e8c4cf589217fba /wkhtmltopdf/tests
parent1acf9a80050054535f056ae1ba40c84e7b52700a (diff)
downloaddjango-wkhtmltopdf-d7bb07ad4468d738f5ba321ee730921f3886e5a3.tar.gz
django-wkhtmltopdf-d7bb07ad4468d738f5ba321ee730921f3886e5a3.tar.bz2
django-wkhtmltopdf-d7bb07ad4468d738f5ba321ee730921f3886e5a3.zip
Fix premature file delete on DEBUG=False. Modify test runner to check both DEBUG options.
Diffstat (limited to 'wkhtmltopdf/tests')
-rw-r--r--wkhtmltopdf/tests/run.py40
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()