summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-16 00:37:36 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-16 00:37:36 (GMT)
commitf21d497b129a88a50fd703a41f4c71bfe70da3d0 (patch)
treea1b6ae0e10c3b57caafd5b2fe3c1a1da1ec3725d /Lib/test
parent0ac51bd1b6f4f78684b7e72385e33303f798ed56 (diff)
downloadcpython-f21d497b129a88a50fd703a41f4c71bfe70da3d0.zip
cpython-f21d497b129a88a50fd703a41f4c71bfe70da3d0.tar.gz
cpython-f21d497b129a88a50fd703a41f4c71bfe70da3d0.tar.bz2
Merged revisions 81226 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r81226 | victor.stinner | 2010-05-16 02:36:38 +0200 (dim., 16 mai 2010) | 11 lines Merged revisions 81224 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r81224 | victor.stinner | 2010-05-16 02:34:40 +0200 (dim., 16 mai 2010) | 4 lines Use with open() as fo: ... instead of try: fo = open(...) finally: fo.close() fo is not set if the open() fails. ........ ................
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/list_tests.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py
index e2889cc..12f4e8f 100644
--- a/Lib/test/list_tests.py
+++ b/Lib/test/list_tests.py
@@ -66,13 +66,11 @@ class CommonTest(seq_tests.CommonTest):
d.append(d)
d.append(400)
try:
- fo = open(support.TESTFN, "w")
- fo.write(str(d))
- fo.close()
- fo = open(support.TESTFN, "r")
- self.assertEqual(fo.read(), repr(d))
+ with open(support.TESTFN, "w") as fo:
+ fo.write(str(d))
+ with open(support.TESTFN, "r") as fo:
+ self.assertEqual(fo.read(), repr(d))
finally:
- fo.close()
os.remove(support.TESTFN)
def test_set_subscript(self):