mirror of https://github.com/celery/kombu.git
Tests passing on Jython
This commit is contained in:
parent
3f28abcb58
commit
5d4110190d
|
@ -17,6 +17,15 @@ try:
|
|||
except ImportError:
|
||||
cpickle = None
|
||||
|
||||
|
||||
if sys.platform.startswith("java"):
|
||||
|
||||
def _decode(t, coding):
|
||||
return codecs.getdecoder(coding)(t)[0]
|
||||
|
||||
else:
|
||||
_decode = codecs.decode
|
||||
|
||||
if sys.version_info < (2, 6): # pragma: no cover
|
||||
# cPickle is broken in Python <= 2.5.
|
||||
# It unsafely and incorrectly uses relative instead of absolute
|
||||
|
@ -117,7 +126,7 @@ class SerializerRegistry(object):
|
|||
# Don't decode 8-bit strings or unicode objects
|
||||
if content_encoding not in ('binary', 'ascii-8bit') and \
|
||||
not isinstance(data, unicode):
|
||||
data = codecs.decode(data, content_encoding)
|
||||
data = _decode(data, content_encoding)
|
||||
|
||||
try:
|
||||
decoder = self._decoders[content_type]
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
from kombu.tests.utils import unittest
|
||||
from nose import SkipTest
|
||||
|
||||
from kombu import compression
|
||||
from kombu.tests.utils import unittest
|
||||
|
||||
|
||||
class test_compression(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
try:
|
||||
import bz2
|
||||
except ImportError:
|
||||
self.has_bzip2 = False
|
||||
else:
|
||||
self.has_bzip2 = True
|
||||
|
||||
def test_encoders(self):
|
||||
encoders = compression.encoders()
|
||||
self.assertIn("application/x-gzip", encoders)
|
||||
self.assertIn("application/x-bz2", encoders)
|
||||
if self.has_bzip2:
|
||||
self.assertIn("application/x-bz2", encoders)
|
||||
|
||||
def test_compress__decompress__zlib(self):
|
||||
text = "The Quick Brown Fox Jumps Over The Lazy Dog"
|
||||
|
@ -18,6 +28,8 @@ class test_compression(unittest.TestCase):
|
|||
self.assertEqual(d, text)
|
||||
|
||||
def test_compress__decompress__bzip2(self):
|
||||
if not self.has_bzip2:
|
||||
raise SkipTest("bzip2 not available")
|
||||
text = "The Brown Quick Fox Over The Lazy Dog Jumps"
|
||||
c, ctype = compression.compress(text, "bzip2")
|
||||
self.assertNotEqual(text, c)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import sys
|
||||
|
||||
############## __builtin__.all ##############################################
|
||||
|
||||
try:
|
||||
|
@ -198,7 +200,13 @@ class CompatOrderedDict(dict, MutableMapping):
|
|||
"""
|
||||
if not self:
|
||||
raise KeyError('dictionary is empty')
|
||||
key = (last and reversed(self) or iter(self)).next()
|
||||
if last:
|
||||
if sys.platform.startswith("java"):
|
||||
key = self.keys()[-1]
|
||||
else:
|
||||
key = reversed(self).next()
|
||||
else:
|
||||
key = iter(self).next()
|
||||
value = self.pop(key)
|
||||
return key, value
|
||||
|
||||
|
|
Loading…
Reference in New Issue