[Python-checkins] python/dist/src/Lib/test test_mimetypes.py, 1.7,
1.8
bwarsaw at users.sourceforge.net
bwarsaw at users.sourceforge.net
Sun Nov 23 11:21:57 EST 2003
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv31749
Modified Files:
test_mimetypes.py
Log Message:
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.
Index: test_mimetypes.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mimetypes.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** test_mimetypes.py 18 Jul 2003 15:13:37 -0000 1.7
--- test_mimetypes.py 23 Nov 2003 16:21:55 -0000 1.8
***************
*** 2,5 ****
--- 2,6 ----
import StringIO
import unittest
+ from sets import Set
from test import test_support
***************
*** 47,54 ****
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'])
# And now non-strict
all = self.db.guess_all_extensions('image/jpg', strict=False)
--- 48,57 ----
def test_guess_all_types(self):
eq = self.assertEqual
! 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)
More information about the Python-checkins
mailing list