summaryrefslogtreecommitdiffstats
path: root/Lib/test/list_tests.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-16 00:35:43 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-16 00:35:43 (GMT)
commitf10d6fb3d97e4663311089c608a86f6b36618002 (patch)
treeb0565b3a23683c652f83e9d36b770eedd5dd34bf /Lib/test/list_tests.py
parent8bdd22a7e64c505613eb896c0c0c90fa0e3ece46 (diff)
downloadcpython-f10d6fb3d97e4663311089c608a86f6b36618002.zip
cpython-f10d6fb3d97e4663311089c608a86f6b36618002.tar.gz
cpython-f10d6fb3d97e4663311089c608a86f6b36618002.tar.bz2
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/list_tests.py')
-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 8dd6de6..9168cfc 100644
--- a/Lib/test/list_tests.py
+++ b/Lib/test/list_tests.py
@@ -57,13 +57,11 @@ class CommonTest(seq_tests.CommonTest):
d.append(d)
d.append(400)
try:
- fo = open(test_support.TESTFN, "wb")
- print >> fo, d,
- fo.close()
- fo = open(test_support.TESTFN, "rb")
- self.assertEqual(fo.read(), repr(d))
+ with open(test_support.TESTFN, "wb") as fo:
+ print >> fo, d,
+ with open(test_support.TESTFN, "rb") as fo:
+ self.assertEqual(fo.read(), repr(d))
finally:
- fo.close()
os.remove(test_support.TESTFN)
def test_set_subscript(self):