[Python-checkins] cpython (merge 3.1 -> 3.2): Merge 3.1

victor.stinner python-checkins at python.org
Mon May 23 14:58:13 CEST 2011


http://hg.python.org/cpython/rev/65d493751830
changeset:   70293:65d493751830
branch:      3.2
parent:      70286:6d67931c63f9
parent:      70292:b538445a9df8
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Mon May 23 14:57:05 2011 +0200
summary:
  Merge 3.1

files:
  Lib/test/test_codecs.py |  13 ++++++-------
  1 files changed, 6 insertions(+), 7 deletions(-)


diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -514,13 +514,11 @@
         s1 = 'Hello\r\nworld\r\n'
 
         s = s1.encode(self.encoding)
-        try:
-            with open(support.TESTFN, 'wb') as fp:
-                fp.write(s)
-            with codecs.open(support.TESTFN, 'U', encoding=self.encoding) as reader:
-                self.assertEqual(reader.read(), s1)
-        finally:
-            support.unlink(support.TESTFN)
+        self.addCleanup(support.unlink, support.TESTFN)
+        with open(support.TESTFN, 'wb') as fp:
+            fp.write(s)
+        with codecs.open(support.TESTFN, 'U', encoding=self.encoding) as reader:
+            self.assertEqual(reader.read(), s1)
 
 class UTF16LETest(ReadTest):
     encoding = "utf-16-le"
@@ -1624,6 +1622,7 @@
                  "utf-32",
                  "utf-32-le",
                  "utf-32-be")
+        self.addCleanup(support.unlink, support.TESTFN)
         for encoding in tests:
             # Check if the BOM is written only once
             with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list