From e4f9b2fc20d61642663db5cae419609b0f06a228 Mon Sep 17 00:00:00 2001 From: Padraic Harley Date: Fri, 29 Jan 2016 12:05:25 +0000 Subject: 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. --- wkhtmltopdf/tests/tests.py | 16 ++++++++-------- 1 file 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, -- cgit v1.2.3