diff --git a/coolamqp/messages.py b/coolamqp/messages.py index c30db8abd4f414b6459bfc524906e2a586fd616f..324a497dec8698ff05f61c1537c15e734e971a60 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 cb702a5128efd9503e8efb1689d54209dde173c3..7535e516b8ec8250b53e81075d55c6b317fcd8a8 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)