summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sys.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-03-25 12:26:07 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-03-25 12:26:07 (GMT)
commitadc3691c214825c5f50d0bb3a52e6e126acf3e67 (patch)
tree06ffe27d5c47755724befe1219aeb5125c687144 /Lib/test/test_sys.py
parent5338f05be3ed7cbb7668533db05dccf9dc5e7f35 (diff)
downloadcpython-adc3691c214825c5f50d0bb3a52e6e126acf3e67.zip
cpython-adc3691c214825c5f50d0bb3a52e6e126acf3e67.tar.gz
cpython-adc3691c214825c5f50d0bb3a52e6e126acf3e67.tar.bz2
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. ........
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r--Lib/test/test_sys.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 73ef6f5..2886e77 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -756,10 +756,15 @@ class SizeofTest(unittest.TestCase):
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)