Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kombu.tests.test_transport_pyredis.test_Redis.test_publish__get fails (with cjson) #18

Closed
fladi opened this issue Feb 2, 2011 · 5 comments

Comments

@fladi
Copy link

fladi commented Feb 2, 2011

Running on python-2.6.6 in Debian Squeeze (again inside build-chroot) this unit test fails because the message body is not decoded. Looking at the test with pdb shows that self.queue(channel).get().payload returns u'{"hello": "world"}' instead of the expected dictionary. Running it outside the chroot does not trigger this problem.

FAIL: test_publish__get (kombu.tests.test_transport_pyredis.test_Redis)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/buildd/kombu-1.0.2/kombu/tests/test_transport_pyredis.py", line 213, in test_publish__get
    {"hello": "world"})
AssertionError: False is not True : First argument is not a dictionary
    'False is not True : First argument is not a dictionary' = self._formatMessage('False is not True : First argument is not a dictionary', "%s is not True" % safe_repr(False))
>>  raise self.failureException('False is not True : First argument is not a dictionary')
@ask
Copy link
Contributor

ask commented Feb 2, 2011

Could you give me the value of

 >>> import anyjson
 >>> anyjson.implementation.name

inside the chroot?

@fladi
Copy link
Author

fladi commented Feb 2, 2011

>>> anyjson.implementation.name
'cjson'

@fladi
Copy link
Author

fladi commented Feb 2, 2011

This seems to be the culprit, outside the chroot it's simplejson:
>>> anyjson.implementation.name
'simplejson'

I forced the installation of simplejson during build--time inside the chroot and now the test works. Still it would be great if kombu worked with cjson too.

@fladi
Copy link
Author

fladi commented Mar 4, 2011

Just an update on this issue, it's not a bug in kombu but in cjson which fails to properly decode a once encoded json string. This affects the decoding of the content_type of a message, resulting in "application/json" for which no decoder can then be found in _decoders. It is documented in Debian BTS: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=534709

This unittest shows the culprit:
import unittest2
from cjson import encode, decode
class TestDecoding(unittest2.TestCase):
def test_encode_decode(self):
original = 'application/json'
self.assertEqual(original, decode(encode(original)))

@ask
Copy link
Contributor

ask commented Mar 28, 2011

cjson is not recommended anymore, and anyjson will show a warning if it is the current implementation.

@ask ask closed this as completed Mar 28, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants