[Python-checkins] cpython (2.7): test_codecs now removes the temporay file (created by the test)
victor.stinner
python-checkins at python.org
Mon May 23 16:19:34 CEST 2011
http://hg.python.org/cpython/rev/10c7fac542e6
changeset: 70295:10c7fac542e6
branch: 2.7
parent: 70284:76e5fe8e21fd
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Mon May 23 16:19:31 2011 +0200
summary:
test_codecs now removes the temporay file (created by the test)
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
@@ -469,13 +469,11 @@
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 @@
"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:
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list