summaryrefslogtreecommitdiff
path: root/gitdb/test/test_util.py
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2016-07-27 09:34:09 +0300
committerVille Skyttä <ville.skytta@iki.fi>2016-07-27 09:34:09 +0300
commitf957c812ac3221773058ba2fa8cd38017537da8a (patch)
tree25e1d8b81197ee3d2a3267ead992e5dbd86b335e /gitdb/test/test_util.py
parentd1996e04dbf4841b853b60c1365f0f5fd28d170c (diff)
downloadgitdb-f957c812ac3221773058ba2fa8cd38017537da8a.tar.gz
Handle more file open/close with "with"
Diffstat (limited to 'gitdb/test/test_util.py')
-rw-r--r--gitdb/test/test_util.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/gitdb/test/test_util.py b/gitdb/test/test_util.py
index 1dee544..c298920 100644
--- a/gitdb/test/test_util.py
+++ b/gitdb/test/test_util.py
@@ -25,19 +25,15 @@ class TestUtils(TestBase):
def _cmp_contents(self, file_path, data):
# raise if data from file at file_path
# does not match data string
- fp = open(file_path, "rb")
- try:
+ with open(file_path, "rb") as fp:
assert fp.read() == data.encode("ascii")
- finally:
- fp.close()
def test_lockedfd(self):
my_file = tempfile.mktemp()
orig_data = "hello"
new_data = "world"
- my_file_fp = open(my_file, "wb")
- my_file_fp.write(orig_data.encode("ascii"))
- my_file_fp.close()
+ with open(my_file, "wb") as my_file_fp:
+ my_file_fp.write(orig_data.encode("ascii"))
try:
lfd = LockedFD(my_file)