summaryrefslogtreecommitdiff
path: root/tests/http_utils/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/http_utils/tests.py')
-rw-r--r--tests/http_utils/tests.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/http_utils/tests.py b/tests/http_utils/tests.py
index 06a310a787..9f99c94da7 100644
--- a/tests/http_utils/tests.py
+++ b/tests/http_utils/tests.py
@@ -11,8 +11,11 @@ from django.test import TestCase
# based on Python 3.3's gzip.compress
def gzip_compress(data):
buf = io.BytesIO()
- with gzip.GzipFile(fileobj=buf, mode='wb', compresslevel=0) as f:
+ f = gzip.GzipFile(fileobj=buf, mode='wb', compresslevel=0)
+ try:
f.write(data)
+ finally:
+ f.close()
return buf.getvalue()