From 588859423a499e58ff1585cae75561e1a43379e1 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sat, 10 Aug 2019 09:52:37 +0100 Subject: [PATCH] issue #615: another Py3x fix. --- tests/ansible/tests/connection_test.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/ansible/tests/connection_test.py b/tests/ansible/tests/connection_test.py index 738aed28..54ea3d99 100644 --- a/tests/ansible/tests/connection_test.py +++ b/tests/ansible/tests/connection_test.py @@ -101,17 +101,17 @@ class OptionalIntTest(testlib.TestCase): class FetchFileTest(ConnectionMixin, testlib.TestCase): def test_success(self): - with tempfile.NamedTemporaryFile(prefix='mitotest') as ifp, \ - tempfile.NamedTemporaryFile(prefix='mitotest') as ofp: - ifp.write(b'x' * (1048576 * 4)) - ifp.flush() - ifp.seek(0) - - self.conn.fetch_file(ifp.name, ofp.name) - # transfer_file() uses os.rename rather than direct data overwrite, - # so we must reopen. - with open(ofp.name, 'rb') as fp: - self.assertEquals(ifp.read(), fp.read()) + with tempfile.NamedTemporaryFile(prefix='mitotest') as ifp: + with tempfile.NamedTemporaryFile(prefix='mitotest') as ofp: + ifp.write(b'x' * (1048576 * 4)) + ifp.flush() + ifp.seek(0) + + self.conn.fetch_file(ifp.name, ofp.name) + # transfer_file() uses os.rename rather than direct data + # overwrite, so we must reopen. + with open(ofp.name, 'rb') as fp: + self.assertEquals(ifp.read(), fp.read()) class PutDataTest(ConnectionMixin, testlib.TestCase):