On Wed, Sep 24, 2003 at 07:10:51AM -0500, Jeff Epler wrote: > Perhaps a better way to fix it would be to test for a superset in > test_mimetypes. assert set(all) >= set('.bat', ...) The general idea is implemented in this patch: --- test_mimetypes.py.orig 2003-09-24 07:11:12.000000000 -0500 +++ test_mimetypes.py 2003-09-24 07:18:58.000000000 -0500 @@ -1,18 +1,21 @@ import mimetypes import StringIO import unittest +import sets from test import test_support -# Tell it we don't know about external files: -mimetypes.knownfiles = [] -mimetypes.inited = False - - class MimeTypesTestCase(unittest.TestCase): def setUp(self): self.db = mimetypes.MimeTypes() + def assertSuperset(self, first, second, msg=None): + first = sets.Set(first) + second = sets.Set(second) + if not first >= second: + raise self.failureException, \ + (msg or '%r >= %r' % (first, second)) + def test_default_data(self): eq = self.assertEqual eq(self.db.guess_type("foo.html"), ("text/html", None)) @@ -45,15 +48,16 @@ eq(self.db.guess_extension('image/jpg', strict=False), '.jpg') def test_guess_all_types(self): + ss = self.assertSuperset eq = self.assertEqual # First try strict all = self.db.guess_all_extensions('text/plain', strict=True) all.sort() - eq(all, ['.bat', '.c', '.h', '.ksh', '.pl', '.txt']) + ss(all, ['.bat', '.c', '.h', '.ksh', '.pl', '.txt']) # And now non-strict all = self.db.guess_all_extensions('image/jpg', strict=False) all.sort() - eq(all, ['.jpg']) + ss(all, ['.jpg']) # And now for no hits all = self.db.guess_all_extensions('image/jpg', strict=True) eq(all, [])
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4