From eb93f82d057b2a58c2ecafac93734b2bbd1c3a77 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 27 Jan 2019 21:48:28 +0000 Subject: [PATCH] tests: ensure file is closed in connection_test. --- tests/ansible/tests/connection_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/ansible/tests/connection_test.py b/tests/ansible/tests/connection_test.py index aaf4bf42..401cbe9e 100644 --- a/tests/ansible/tests/connection_test.py +++ b/tests/ansible/tests/connection_test.py @@ -96,7 +96,11 @@ class PutFileTest(ConnectionMixin, unittest2.TestCase): def setUpClass(cls): super(PutFileTest, cls).setUpClass() cls.big_path = tempfile.mktemp(prefix='mitotestbig') - open(cls.big_path, 'w').write('x'*1048576) + fp = open(cls.big_path, 'w') + try: + fp.write('x'*1048576) + finally: + fp.close() @classmethod def tearDownClass(cls):