From 14faa46363125166302a29234338ac3e0f72ae9c Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Thu, 11 May 2017 17:25:14 +0100 Subject: [PATCH] Use with-block when writing to file --- gramps/test/test/test_util_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gramps/test/test/test_util_test.py b/gramps/test/test/test_util_test.py index 9072a2c25..e1dc348f3 100644 --- a/gramps/test/test/test_util_test.py +++ b/gramps/test/test/test_util_test.py @@ -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),