From 9a521681ff8614beb8e2c566cf3c475baca22169 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Sat, 1 Oct 2016 18:20:13 +0200 Subject: io, #519: ALL open() --> with open() + Some cases had restructuring of code. --- git/test/test_base.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'git/test/test_base.py') diff --git a/git/test/test_base.py b/git/test/test_base.py index fa0bebca..e5e8f173 100644 --- a/git/test/test_base.py +++ b/git/test/test_base.py @@ -77,13 +77,11 @@ class TestBase(TestBase): assert data tmpfilename = tempfile.mktemp(suffix='test-stream') - tmpfile = open(tmpfilename, 'wb+') - assert item == item.stream_data(tmpfile) - tmpfile.seek(0) - assert tmpfile.read() == data - tmpfile.close() + with open(tmpfilename, 'wb+') as tmpfile: + assert item == item.stream_data(tmpfile) + tmpfile.seek(0) + assert tmpfile.read() == data os.remove(tmpfilename) - # END stream to file directly # END for each object type to create # each has a unique sha @@ -133,7 +131,8 @@ class TestBase(TestBase): from nose import SkipTest raise SkipTest("Environment doesn't support unicode filenames") - open(file_path, "wb").write(b'something') + with open(file_path, "wb") as fp: + fp.write(b'something') if is_win: # on windows, there is no way this works, see images on -- cgit v1.2.1