Jason R. Coombs committed f12eb50

Fixed failing test case when mimetypes.guess_type('foo.jpeg')[0] == 'image/pjpeg'

Comments (0)

Files changed (2)


         # Test static in config
         self.getPage("/static2/dirback.jpg", [('Host', '')])
         self.assertStatus('200 OK')
-        self.assertHeader('Content-Type', 'image/jpeg')
+        self.assertHeaderIn('Content-Type', ['image/jpeg', 'image/pjpeg'])
         # Test static config with "index" arg
         self.getPage("/static2/", [('Host', '')])


 from cherrypy._cpcompat import basestring, ntob, py3k, HTTPConnection, HTTPSConnection, unicodestr
 def interface(host):
     """Return an IP address for a client connection given the server host.
                 msg = '%r:%r not in headers' % (key, value)
+    def assertHeaderIn(self, key, values, msg=None):
+        """Fail if header indicated by key doesn't have one of the values."""
+        lowkey = key.lower()
+        for k, v in self.headers:
+            if k.lower() == lowkey:
+                matches = [value for value in values if str(value) == v]
+                if matches:
+                    return matches
+        if msg is None:
+            msg = '%(key)r not in %(values)r' % vars()
+        self._handlewebError(msg)
     def assertHeaderItemValue(self, key, value, msg=None):
         """Fail if the header does not contain the specified value"""
         actual_value = self.assertHeader(key, msg=msg)