From 8e64238e109e6a4ec741d76c1856665e6d80ae00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Sun, 25 Dec 2016 00:05:11 +0100 Subject: [PATCH] a minor bug --- coolamqp/messages.py | 4 +--- tests/test_basics.py | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/coolamqp/messages.py b/coolamqp/messages.py index c30db8a..324a497 100644 --- a/coolamqp/messages.py +++ b/coolamqp/messages.py @@ -13,9 +13,7 @@ class Message(object): :type body: str (py2) or bytes (py3) :param properties: AMQP properties to be sent along """ - if not isinstance(body, six.binary_type): - raise TypeError('Message body must be binary!') - self.body = body + self.body = six.binary_type(body) self.properties = {} if properties is None else properties diff --git a/tests/test_basics.py b/tests/test_basics.py index cb702a5..7535e51 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -45,6 +45,9 @@ class TestBasics(unittest.TestCase): def test_send_bullshit(self): self.assertRaises(TypeError, lambda: Message(u'what the fuck')) + def test_send_nonobvious_bullshit(self): + self.assertEquals(Message(bytearray(b'what the fuck')).body, b'what the fuck') + def test_nacknowledge(self): myq = Queue('myqueue', exclusive=True) -- GitLab