close resources and 80-char line width
| | |
| | | def __init__(self, path, request=None, cache_max_age=None, |
| | | content_type=None, content_encoding=None): |
| | | if content_type is None: |
| | | content_type, content_encoding = mimetypes.guess_type(path, strict=False) |
| | | content_type, content_encoding = ( |
| | | mimetypes.guess_type(path, strict=False)) |
| | | if content_type is None: |
| | | content_type = 'application/octet-stream' |
| | | super(FileResponse, self).__init__( |
| | |
| | | |
| | | def _getPath(self, suffix='txt'): |
| | | here = os.path.dirname(__file__) |
| | | return os.path.join(here, 'fixtures', 'minimal.%s'%(suffix,)) |
| | | return os.path.join(here, 'fixtures', 'minimal.%s' % (suffix,)) |
| | | |
| | | def test_with_image_content_type(self): |
| | | path = self._getPath('jpg') |
| | |
| | | self.assertEqual(r.content_type, 'image/jpeg') |
| | | self.assertEqual(r.headers['content-type'], 'image/jpeg') |
| | | path = self._getPath() |
| | | r.app_iter.close() |
| | | |
| | | 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') |
| | | self.assertEqual(r.headers['content-type'], |
| | | 'application/xml; charset=UTF-8') |
| | | r.app_iter.close() |
| | | |
| | | def test_with_pdf_content_type(self): |