Use with-block when writing to file
This commit is contained in:
parent
1b18b652bb
commit
14faa46363
@ -166,7 +166,8 @@ class Test3(U.TestCase):
|
||||
self.assertTrue(os.path.isdir(s2), "made dir %r" % s2)
|
||||
f = os.path.join(s2,"test_file")
|
||||
|
||||
open(f,"w").write("testing..")
|
||||
with open(f, "w") as fd:
|
||||
fd.write("testing..")
|
||||
self.assertTrue(os.path.isfile(f), "file %r exists" % f)
|
||||
tu.delete_tree(sub)
|
||||
self.assertFalse(os.path.isdir(sub),
|
||||
|
Loading…
Reference in New Issue
Block a user