summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-23 16:19:31 +0200
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-23 16:19:31 +0200
commitb5e277ca522d94bdbf1426bfd8c43fee2f8153f3 (patch)
treead1b5c56a1cd7de261e35819133502b4180278f0 /Lib
parent8a9762f029dece5648224936c8e1b44b3b6928e2 (diff)
downloadcpython-b5e277ca522d94bdbf1426bfd8c43fee2f8153f3.tar.gz
test_codecs now removes the temporay file (created by the test)
Diffstat (limited to 'Lib')
-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 7cd7141b06..f7f27cc7d9 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -469,13 +469,11 @@ class UTF16Test(ReadTest):
s1 = u'Hello\r\nworld\r\n'
s = s1.encode(self.encoding)
- try:
- with open(test_support.TESTFN, 'wb') as fp:
- fp.write(s)
- with codecs.open(test_support.TESTFN, 'U', encoding=self.encoding) as reader:
- self.assertEqual(reader.read(), s1)
- finally:
- test_support.unlink(test_support.TESTFN)
+ self.addCleanup(test_support.unlink, test_support.TESTFN)
+ with open(test_support.TESTFN, 'wb') as fp:
+ fp.write(s)
+ with codecs.open(test_support.TESTFN, 'U', encoding=self.encoding) as reader:
+ self.assertEqual(reader.read(), s1)
class UTF16LETest(ReadTest):
encoding = "utf-16-le"
@@ -1532,6 +1530,7 @@ class BomTest(unittest.TestCase):
"utf-32",
"utf-32-le",
"utf-32-be")
+ self.addCleanup(test_support.unlink, test_support.TESTFN)
for encoding in tests:
# Check if the BOM is written only once
with codecs.open(test_support.TESTFN, 'w+', encoding=encoding) as f: