From c8a58abb1ed5705defb7d7464e4f0d086fe13a21 Mon Sep 17 00:00:00 2001 From: Dobes Vandermeer Date: Thu, 6 Mar 2014 21:29:52 -0800 Subject: Expand tests - make sure pdf, jpeg types also are not annotated with a charset. --- pyramid/tests/fixtures/minimal.jpg | Bin 0 -> 631 bytes pyramid/tests/test_response.py | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 pyramid/tests/fixtures/minimal.jpg diff --git a/pyramid/tests/fixtures/minimal.jpg b/pyramid/tests/fixtures/minimal.jpg new file mode 100644 index 000000000..1cda9a53d Binary files /dev/null and b/pyramid/tests/fixtures/minimal.jpg differ diff --git a/pyramid/tests/test_response.py b/pyramid/tests/test_response.py index afd354d97..8061ecac5 100644 --- a/pyramid/tests/test_response.py +++ b/pyramid/tests/test_response.py @@ -27,17 +27,27 @@ class TestFileResponse(unittest.TestCase): here = os.path.dirname(__file__) return os.path.join(here, 'fixtures', 'minimal.%s'%(suffix,)) - def test_with_content_type(self): - path = self._getPath() + def test_with_image_content_type(self): + path = self._getPath('jpg') r = self._makeOne(path, content_type='image/jpeg') self.assertEqual(r.content_type, 'image/jpeg') - self.assertEqual(r.headers.get('content-type'), 'image/jpeg') + self.assertEqual(r.headers['content-type'], 'image/jpeg') path = self._getPath() + + def test_with_xml_content_type(self): + path = self._getPath('xml') r = self._makeOne(path, content_type='application/xml') self.assertEqual(r.content_type, 'application/xml') self.assertEqual(r.headers['content-type'], 'application/xml; charset=UTF-8') r.app_iter.close() + def test_with_pdf_content_type(self): + path = self._getPath('xml') + r = self._makeOne(path, content_type='application/pdf') + self.assertEqual(r.content_type, 'application/pdf') + self.assertEqual(r.headers['content-type'], 'application/pdf') + r.app_iter.close() + def test_without_content_type(self): for suffix, content_type in ( ('txt', 'text/plain; charset=UTF-8'), -- cgit v1.2.3