diff options
| author | Florian Apolloner <florian@apolloner.eu> | 2013-05-21 04:20:35 -0700 |
|---|---|---|
| committer | Florian Apolloner <florian@apolloner.eu> | 2013-05-21 04:20:35 -0700 |
| commit | 800513e7f3f8e4db26b40ecd2f8aae25ecc3191b (patch) | |
| tree | 58e4420e09176e16b8cdc9c8d436d17b718468bd /tests/http_utils/tests.py | |
| parent | cec9558fba1bc6401ea2ec6d71b816b4dfd31b28 (diff) | |
| parent | c28281f9d60b12e29481214348abc6084c31d77d (diff) | |
Merge pull request #1194 from ambv/python26_is_fun
Fixed a Python 2.6 regression (GzipFile can't act as a context manager)
Diffstat (limited to 'tests/http_utils/tests.py')
| -rw-r--r-- | tests/http_utils/tests.py | 5 |
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() |
