aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPadraic Harley <padraic@thelodgeronline.com>2016-01-29 12:05:25 +0000
committerPadraic Harley <padraic@thelodgeronline.com>2016-01-29 12:05:25 +0000
commite4f9b2fc20d61642663db5cae419609b0f06a228 (patch)
treeb5b6bf278aa2ee724866efe678b75908c2042896
parentc51068cd1864d995e81ee5fd248b8a2027e56c35 (diff)
downloaddjango-wkhtmltopdf-e4f9b2fc20d61642663db5cae419609b0f06a228.tar.gz
django-wkhtmltopdf-e4f9b2fc20d61642663db5cae419609b0f06a228.tar.bz2
django-wkhtmltopdf-e4f9b2fc20d61642663db5cae419609b0f06a228.zip
Assert once but get the filename from the ImportError
It was pointed out that instead setting the filename from the ``except/else`` makes what's being tested much clearer.
-rw-r--r--wkhtmltopdf/tests/tests.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/wkhtmltopdf/tests/tests.py b/wkhtmltopdf/tests/tests.py
index fc1545d..5344e09 100644
--- a/wkhtmltopdf/tests/tests.py
+++ b/wkhtmltopdf/tests/tests.py
@@ -133,11 +133,11 @@ class TestViews(TestCase):
try:
import unidecode
except ImportError:
- self.assertEqual(response['Content-Disposition'],
- 'attachment; filename="?.pdf"')
+ filename = '?.pdf'
else:
- self.assertEqual(response['Content-Disposition'],
- 'attachment; filename=".pdf"')
+ filename = '.pdf'
+ self.assertEqual(response['Content-Disposition'],
+ 'attachment; filename="{}"'.format(filename))
# Content as a direct output
response = PDFResponse(content=content, filename="nospace.pdf",
@@ -157,11 +157,11 @@ class TestViews(TestCase):
try:
import unidecode
except ImportError:
- self.assertEqual(response['Content-Disposition'],
- 'inline; filename="?.pdf"')
+ filename = '?.pdf'
else:
- self.assertEqual(response['Content-Disposition'],
- 'inline; filename=".pdf"')
+ filename = '.pdf'
+ self.assertEqual(response['Content-Disposition'],
+ 'attachment; filename="{}"'.format(filename))
# Content-Type
response = PDFResponse(content=content,