Skip to content

Commit

Permalink
Removed Jython bz2 import fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
atombrella committed Oct 28, 2018
1 parent 110dc10 commit 172a585
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
13 changes: 5 additions & 8 deletions kombu/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from kombu.utils.encoding import ensure_bytes

import bz2
import zlib

_aliases = {}
Expand Down Expand Up @@ -70,11 +71,7 @@ def decompress(body, content_type):
register(zlib.compress,
zlib.decompress,
'application/x-gzip', aliases=['gzip', 'zlib'])
try:
import bz2
except ImportError:
pass # Jython?
else:
register(bz2.compress,
bz2.decompress,
'application/x-bz2', aliases=['bzip2', 'bzip'])

register(bz2.compress,
bz2.decompress,
'application/x-bz2', aliases=['bzip2', 'bzip'])
16 changes: 0 additions & 16 deletions t/unit/test_compression.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
from __future__ import absolute_import, unicode_literals

import sys

from case import mock, skip

from kombu import compression


class test_compression:

@mock.mask_modules('bz2')
def test_no_bz2(self):
c = sys.modules.pop('kombu.compression')
try:
import kombu.compression
assert not hasattr(kombu.compression, 'bz2')
finally:
if c is not None:
sys.modules['kombu.compression'] = c

def test_encoders__gzip(self):
assert 'application/x-gzip' in compression.encoders()

@skip.unless_module('bz2')
def test_encoders__bz2(self):
assert 'application/x-bz2' in compression.encoders()

Expand All @@ -33,7 +18,6 @@ def test_compress__decompress__zlib(self):
d = compression.decompress(c, ctype)
assert d == text

@skip.unless_module('bz2')
def test_compress__decompress__bzip2(self):
text = b'The Brown Quick Fox Over The Lazy Dog Jumps'
c, ctype = compression.compress(text, 'bzip2')
Expand Down

0 comments on commit 172a585

Please sign in to comment.