[Python-checkins] r79421 - in python/branches/release31-maint: Lib/test/test_sys.py

victor.stinner python-checkins at python.org
Thu Mar 25 13:26:07 CET 2010


Author: victor.stinner
Date: Thu Mar 25 13:26:07 2010
New Revision: 79421
Log:
Merged revisions 79420 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
 r79420 | victor.stinner | 2010年03月25日 13:24:38 +0100 (jeu., 25 mars 2010) | 10 lines
 
 Fix my test introduced in test_sys by r79394:
 
 Restore the orginal filesystem encoding before testing
 assertRaises(LookupError, sys.setfilesystemencoding, "xxx"). Unittest formats
 the exception, but the formatting failed because the file system was invalid
 (set to iso-8859-1 by the previous test).
 
 Anyway, ensure to restore the original filesystem encoding when exiting
 test_setfilesystemencoding() to avoid error propagation to the other tests.
........
Modified:
 python/branches/release31-maint/ (props changed)
 python/branches/release31-maint/Lib/test/test_sys.py
Modified: python/branches/release31-maint/Lib/test/test_sys.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_sys.py	(original)
+++ python/branches/release31-maint/Lib/test/test_sys.py	Thu Mar 25 13:26:07 2010
@@ -756,10 +756,15 @@
 
 def test_setfilesystemencoding(self):
 old = sys.getfilesystemencoding()
- sys.setfilesystemencoding("iso-8859-1")
- self.assertEqual(sys.getfilesystemencoding(), "iso-8859-1")
- self.assertRaises(LookupError, sys.setfilesystemencoding, "xxx")
- sys.setfilesystemencoding(old)
+ try:
+ sys.setfilesystemencoding("iso-8859-1")
+ self.assertEqual(sys.getfilesystemencoding(), "iso-8859-1")
+ finally:
+ sys.setfilesystemencoding(old)
+ try:
+ self.assertRaises(LookupError, sys.setfilesystemencoding, "xxx")
+ finally:
+ sys.setfilesystemencoding(old)
 
 def test_main():
 test.support.run_unittest(SysModuleTest, SizeofTest)


More information about the Python-checkins mailing list

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