diff options
author | Barry Warsaw <barry@python.org> | 2003-11-23 16:21:55 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2003-11-23 16:21:55 (GMT) |
commit | ceca5d29243cae41f5304fa16bf54b7258f6ad42 (patch) | |
tree | 34035b0254f88c985ffac44087d0ae6ddc0b0080 | |
parent | 49ba4c39c49ff6b1db666e6c90365fc1361c4a64 (diff) | |
download | cpython-ceca5d29243cae41f5304fa16bf54b7258f6ad42.zip cpython-ceca5d29243cae41f5304fa16bf54b7258f6ad42.tar.gz cpython-ceca5d29243cae41f5304fa16bf54b7258f6ad42.tar.bz2 |
test_guess_all_types(): Use a more robust test for checking that
guess_all_extensions() returns (at least) what we expect. As Jeff
Epler suggests in
http://mail.python.org/pipermail/python-dev/2003-September/038264.html
We use a set to test the results. This fixes the test when
test_urllib2 is run before test_mimetypes.
-rw-r--r-- | Lib/test/test_mimetypes.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index fed0bf5..5939ff5 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -1,6 +1,7 @@ import mimetypes import StringIO import unittest +from sets import Set from test import test_support @@ -46,10 +47,12 @@ class MimeTypesTestCase(unittest.TestCase): def test_guess_all_types(self): 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']) + unless = self.failUnless + # First try strict. Use a set here for testing the results because if + # test_urllib2 is run before test_mimetypes, global state is modified + # such that the 'all' set will have more items in it. + all = Set(self.db.guess_all_extensions('text/plain', strict=True)) + unless(all >= Set(['.bat', '.c', '.h', '.ksh', '.pl', '.txt'])) # And now non-strict all = self.db.guess_all_extensions('image/jpg', strict=False) all.sort() |