summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_codecs.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-23 12:58:07 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-23 12:58:07 (GMT)
commitd6881701fba738db55e13d92b4f4770ffd5114c9 (patch)
tree8f360193a6d03789f0188c2b5255127452fe6651 /Lib/test/test_codecs.py
parentcc6491a0faab5e57e6e004fd07a5b5ecf2762786 (diff)
parentb43dd4b8ca2deaeab818fa996330ad8fe99b09e6 (diff)
downloadcpython-d6881701fba738db55e13d92b4f4770ffd5114c9.zip
cpython-d6881701fba738db55e13d92b4f4770ffd5114c9.tar.gz
cpython-d6881701fba738db55e13d92b4f4770ffd5114c9.tar.bz2
Merge 3.2
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r--Lib/test/test_codecs.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 67a5aed..c0450e7 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -514,13 +514,11 @@ class UTF16Test(ReadTest):
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 @@ class BomTest(unittest.TestCase):
"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: