From a2fb2b3a1feee512131c76e9040232faf2362526 Mon Sep 17 00:00:00 2001 From: Ville Skyttä Date: Fri, 5 Aug 2016 02:45:14 +0300 Subject: Fixed #27020 -- Used a context manager to close files. --- tests/test_client/test_conditional_content_removal.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/test_client/test_conditional_content_removal.py b/tests/test_client/test_conditional_content_removal.py index cc5bdb69ed..644eb23a06 100644 --- a/tests/test_client/test_conditional_content_removal.py +++ b/tests/test_client/test_conditional_content_removal.py @@ -11,11 +11,8 @@ from django.test.client import conditional_content_removal # based on Python 3.3's gzip.compress def gzip_compress(data): buf = io.BytesIO() - f = gzip.GzipFile(fileobj=buf, mode='wb', compresslevel=0) - try: + with gzip.GzipFile(fileobj=buf, mode='wb', compresslevel=0) as f: f.write(data) - finally: - f.close() return buf.getvalue() -- cgit v1.3