[Python-checkins] CVS: python/dist/src/Lib/test test_mimetypes.py,1.2,1.3

Barry Warsaw bwarsaw@users.sourceforge.net
2001年10月25日 14:49:20 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv31010/Lib/test
Modified Files:
	test_mimetypes.py 
Log Message:
Applying proposed patch for bug #474583, optional support for
non-standard but common types. Including Martin's suggestion to add
rejected non-standard types from patch #438790. Specifically,
guess_type(), guess_extension(): Both the functions and the methods
grow an optional "strict" flag, defaulting to true, which determines
whether to recognize non-standard, but commonly found types or not.
Also, I sorted, reformatted, and culled duplicates from the big
types_map dictionary. Note that there are a few non-equivalent
duplicates (e.g. .cdf and .xls) for which the first will just get
thrown away. I didn't remove those though.
Finally, use of the module as a script as grown the -l and -e options
to toggle strictness and to do guess_extension(), respectively.
Doc and unittest updates too.
Index: test_mimetypes.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mimetypes.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_mimetypes.py	2001年09月20日 21:33:42	1.2
--- test_mimetypes.py	2001年10月25日 21:49:18	1.3
***************
*** 39,42 ****
--- 39,54 ----
 ".pyunit")
 
+ def test_non_standard_types(self):
+ # First try strict 
+ self.assertEqual(self.db.guess_type('foo.xul', strict=1),
+ (None, None))
+ self.assertEqual(self.db.guess_extension('image/jpg', strict=1),
+ None)
+ # And then non-strict
+ self.assertEqual(self.db.guess_type('foo.xul', strict=0),
+ ('text/xul', None))
+ self.assertEqual(self.db.guess_extension('image/jpg', strict=0),
+ '.jpg')
+ 
 
 def test_main():

AltStyle によって変換されたページ (->オリジナル) /