summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-03-25 12:24:38 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-03-25 12:24:38 (GMT)
commit4ce881e928fc2dfd15a4ffafcf59ed71e51f2d24 (patch)
tree9c389ef6074766c1e40688cb9f489d3c49b60c72 /Lib
parente777a68682ec1234962659db32b46b29b05adb3c (diff)
downloadcpython-4ce881e928fc2dfd15a4ffafcf59ed71e51f2d24.zip
cpython-4ce881e928fc2dfd15a4ffafcf59ed71e51f2d24.tar.gz
cpython-4ce881e928fc2dfd15a4ffafcf59ed71e51f2d24.tar.bz2
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')
-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 23ec399..1b21f50 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -797,10 +797,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)