mirror of https://github.com/celery/kombu.git
Added optional support for brotli compression (#983)
* Added optional support for brotli compression. * Ignore import error for coverage purposes.
This commit is contained in:
parent
fa0cb19d27
commit
93a05f7261
|
@ -76,3 +76,12 @@ register(zlib.compress,
|
|||
register(bz2.compress,
|
||||
bz2.decompress,
|
||||
'application/x-bz2', aliases=['bzip2', 'bzip'])
|
||||
|
||||
try:
|
||||
import brotli
|
||||
except ImportError: # pragma: no cover
|
||||
pass
|
||||
else:
|
||||
register(brotli.compress,
|
||||
brotli.decompress,
|
||||
'application/x-brotli', aliases=['brotli'])
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
brotlipy>=0.7.0;python_implementation=="PyPy"
|
||||
brotli>=1.0.0;python_implementation=="CPython"
|
|
@ -9,4 +9,5 @@ msgpack-python>0.2.0
|
|||
-r extras/consul.txt
|
||||
-r extras/librabbitmq.txt
|
||||
-r extras/zookeeper.txt
|
||||
-r extras/brotli.txt
|
||||
sqlalchemy
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import pytest
|
||||
|
||||
from kombu import compression
|
||||
|
||||
|
||||
|
@ -11,6 +13,11 @@ class test_compression:
|
|||
def test_encoders__bz2(self):
|
||||
assert 'application/x-bz2' in compression.encoders()
|
||||
|
||||
def test_encoders__brotli(self):
|
||||
pytest.importorskip('brotli')
|
||||
|
||||
assert 'application/x-brotli' in compression.encoders()
|
||||
|
||||
def test_compress__decompress__zlib(self):
|
||||
text = b'The Quick Brown Fox Jumps Over The Lazy Dog'
|
||||
c, ctype = compression.compress(text, 'zlib')
|
||||
|
@ -24,3 +31,12 @@ class test_compression:
|
|||
assert text != c
|
||||
d = compression.decompress(c, ctype)
|
||||
assert d == text
|
||||
|
||||
def test_compress__decompress__brotli(self):
|
||||
pytest.importorskip('brotli')
|
||||
|
||||
text = b'The Brown Quick Fox Over The Lazy Dog Jumps'
|
||||
c, ctype = compression.compress(text, 'brotli')
|
||||
assert text != c
|
||||
d = compression.decompress(c, ctype)
|
||||
assert d == text
|
||||
|
|
Loading…
Reference in New Issue