summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Langa <lukasz@langa.pl>2013-05-21 13:18:53 +0200
committerŁukasz Langa <lukasz@langa.pl>2013-05-21 13:18:53 +0200
commitc28281f9d60b12e29481214348abc6084c31d77d (patch)
tree36ae32f3ce081059c54260d72dfa5dbbbb2bd5ee
parentb1ac241ddc8e496fae9bee5e88511d5698c18ca5 (diff)
Fixed a Python 2.6 regression (GzipFile can't act as a context manager)
-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()