mirror of
https://github.com/python/cpython.git
synced 2025-08-19 08:11:46 +00:00
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. ........
This commit is contained in:
parent
8bdd22a7e6
commit
f10d6fb3d9
1 changed files with 4 additions and 6 deletions
|
@ -57,13 +57,11 @@ class CommonTest(seq_tests.CommonTest):
|
||||||
d.append(d)
|
d.append(d)
|
||||||
d.append(400)
|
d.append(400)
|
||||||
try:
|
try:
|
||||||
fo = open(test_support.TESTFN, "wb")
|
with open(test_support.TESTFN, "wb") as fo:
|
||||||
print >> fo, d,
|
print >> fo, d,
|
||||||
fo.close()
|
with open(test_support.TESTFN, "rb") as fo:
|
||||||
fo = open(test_support.TESTFN, "rb")
|
self.assertEqual(fo.read(), repr(d))
|
||||||
self.assertEqual(fo.read(), repr(d))
|
|
||||||
finally:
|
finally:
|
||||||
fo.close()
|
|
||||||
os.remove(test_support.TESTFN)
|
os.remove(test_support.TESTFN)
|
||||||
|
|
||||||
def test_set_subscript(self):
|
def test_set_subscript(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue