Commits

Jason R. Coombs committed f12eb50

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

Comments (0)

Files changed (2)

cherrypy/test/test_virtualhost.py

         # Test static in config
         self.getPage("/static2/dirback.jpg", [('Host', 'www.mydom2.com')])
         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', 'www.mydom2.com')])

cherrypy/test/webtest.py

 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)
         self._handlewebError(msg)
 
+    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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.