From 3b9b511708f987254fdcfdc5fc0f020d7a0ab923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Fri, 5 Nov 2010 23:51:56 +0000 Subject: Always close files in distutils code and tests (#10252). --- tests/test_dir_util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/test_dir_util.py') diff --git a/tests/test_dir_util.py b/tests/test_dir_util.py index a1647fbc..aa9f9ebb 100644 --- a/tests/test_dir_util.py +++ b/tests/test_dir_util.py @@ -88,8 +88,10 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase): mkpath(self.target, verbose=0) a_file = os.path.join(self.target, 'ok.txt') f = open(a_file, 'w') - f.write('some content') - f.close() + try: + f.write('some content') + finally: + f.close() wanted = ['copying %s -> %s' % (a_file, self.target2)] copy_tree(self.target, self.target2, verbose=1) -- cgit v1.2.1