summaryrefslogtreecommitdiff
path: root/funtests/test_serialization.py
diff options
context:
space:
mode:
Diffstat (limited to 'funtests/test_serialization.py')
-rwxr-xr-xfuntests/test_serialization.py59
1 files changed, 6 insertions, 53 deletions
diff --git a/funtests/test_serialization.py b/funtests/test_serialization.py
index 9a8793c..ce70438 100755
--- a/funtests/test_serialization.py
+++ b/funtests/test_serialization.py
@@ -26,12 +26,6 @@ from random import randint
import sys
import unittest
-try:
- bytes
-except NameError:
- # Python 2.5 and lower
- bytes = str
-
import settings
from amqp.serialization import (
@@ -316,7 +310,7 @@ class TestSerialization(unittest.TestCase):
Check that an un-serializable table entry raises a ValueError
"""
- val = {'test': None}
+ val = {'test': object()}
w = AMQPWriter()
self.assertRaises(FrameSyntaxError, w.write_table, val)
@@ -327,6 +321,7 @@ class TestSerialization(unittest.TestCase):
'baz': 'this is some random string I typed',
'ubaz': u'And something in unicode',
'dday_aniv': datetime(1994, 6, 6),
+ 'nothing': None,
'more': {
'abc': -123,
'def': 'hello world',
@@ -351,26 +346,26 @@ class TestSerialization(unittest.TestCase):
# Array
#
def test_array_from_list(self):
- val = [1, 'foo']
+ val = [1, 'foo', None]
w = AMQPWriter()
w.write_array(val)
s = w.getvalue()
self.assertEqualBinary(
- s, '\x00\x00\x00\x0DI\x00\x00\x00\x01S\x00\x00\x00\x03foo',
+ s, '\x00\x00\x00\x0EI\x00\x00\x00\x01S\x00\x00\x00\x03fooV',
)
r = AMQPReader(s)
self.assertEqual(r.read_array(), val)
def test_array_from_tuple(self):
- val = (1, 'foo')
+ val = (1, 'foo', None)
w = AMQPWriter()
w.write_array(val)
s = w.getvalue()
self.assertEqualBinary(
- s, '\x00\x00\x00\x0DI\x00\x00\x00\x01S\x00\x00\x00\x03foo',
+ s, '\x00\x00\x00\x0EI\x00\x00\x00\x01S\x00\x00\x00\x03fooV',
)
r = AMQPReader(s)
@@ -394,48 +389,6 @@ class TestSerialization(unittest.TestCase):
self.assertEqual(r.read_table(), val)
#
- # Array
- #
- def test_array_from_list(self):
- val = [1, 'foo']
- w = AMQPWriter()
- w.write_array(val)
- s = w.getvalue()
-
- self.assertEqualBinary(s, '\x00\x00\x00\x0DI\x00\x00\x00\x01S\x00\x00\x00\x03foo')
-
- r = AMQPReader(s)
- self.assertEqual(r.read_array(), val)
-
- def test_array_from_tuple(self):
- val = (1, 'foo')
- w = AMQPWriter()
- w.write_array(val)
- s = w.getvalue()
-
- self.assertEqualBinary(s, '\x00\x00\x00\x0DI\x00\x00\x00\x01S\x00\x00\x00\x03foo')
-
- r = AMQPReader(s)
- self.assertEqual(r.read_array(), list(val))
-
- def test_table_with_array(self):
- val = {
- 'foo': 7,
- 'bar': Decimal('123345.1234'),
- 'baz': 'this is some random string I typed',
- 'blist': [1,2,3],
- 'nlist': [1, [2,3,4]],
- 'ndictl': {'nfoo': 8, 'nblist': [5,6,7] }
- }
-
- w = AMQPWriter()
- w.write_table(val)
- s = w.getvalue()
-
- r = AMQPReader(s)
- self.assertEqual(r.read_table(), val)
-
- #
# GenericContent
#
def test_generic_content_eq(self):