def test_roundtrip(self): format = b"bobBlLbsbST" x = dumps( format, [ True, 32, False, 3415, 4513134, 13241923419, True, b"thequickbrownfox", False, "jumpsoverthelazydog", datetime(2015, 3, 13, 10, 23), ], ) y = loads(format, x) self.assertListEqual( [ True, 32, False, 3415, 4513134, 13241923419, True, "thequickbrownfox", False, "jumpsoverthelazydog", ANY(), ], y[0], )
def test_int_boundaries(self): format = b'F' x = dumps(format, [ {'a': -2147483649, 'b': 2147483648}, # celery/celery#3121 ]) y = loads(format, x) assert y[0] == [{ 'a': -2147483649, 'b': 2147483648, # celery/celery#3121 }]
def test_table(self): table = { 'foo': 32, 'bar': 'baz', 'nil': None, 'array': [ 1, True, 'bar' ] } assert loads(b'F', dumps(b'F', [table]))[0][0] == table
def test_roundtrip(self): format = b'bobBlLbsbST' x = dumps(format, [ True, 32, False, 3415, 4513134, 13241923419, True, b'thequickbrownfox', False, 'jumpsoverthelazydog', datetime(2015, 3, 13, 10, 23), ]) y = loads(format, x) assert [ True, 32, False, 3415, 4513134, 13241923419, True, 'thequickbrownfox', False, 'jumpsoverthelazydog', datetime(2015, 3, 13, 10, 23), ] == y[0]
def test_array(self): array = [ 'A', 1, True, 33.3, Decimal('55.5'), Decimal('-3.4'), datetime(2015, 3, 13, 10, 23), {'quick': 'fox', 'amount': 1}, [3, 'hens'], None, ] expected = list(array) expected[6] = _ANY() assert expected == loads('A', dumps('A', [array]))[0][0]
def test_array(self): array = [ "A", 1, True, 33.3, Decimal("55.5"), Decimal("-3.4"), datetime(2015, 3, 13, 10, 23), {"quick": "fox", "amount": 1}, [3, "hens"], None, ] expected = list(array) expected[6] = ANY() self.assertListEqual(expected, loads("A", dumps("A", [array]))[0][0])
def test_sixteen_bitflags(self): expected = [True, False] * 8 format = 'b' * len(expected) buf = dumps(format, expected) actual, _ = loads(format, buf, 0) assert actual == expected
def test_table(self): table = {"foo": 32, "bar": "baz", "nil": None} self.assertDictEqual(loads(b"F", dumps(b"F", [table]))[0][0], table)
def test_float(self): self.assertEqual(int(loads(b"fb", dumps(b"fb", [32.31, False]))[0][0] * 100), 3231)
def test_loads_unknown_type(self): with self.assertRaises(FrameSyntaxError): loads("x", "asdsad")
def test_float(self): self.assertEqual( int(loads(b'fb', dumps(b'fb', [32.31, False]))[0][0] * 100), 3231, )
def test_float(self): assert (int(loads(b'fb', dumps(b'fb', [32.31, False]))[0][0] * 100) == 3231)
def test_loads_unknown_type(self): with self.assertRaises(FrameSyntaxError): loads('x', 'asdsad')
def test_table(self): table = {'foo': 32, 'bar': 'baz', 'nil': None} self.assertDictEqual( loads(b'F', dumps(b'F', [table]))[0][0], table, )
def __eq__(self, other): values, offset = loads(self.argsig, other) return tuple(values) == tuple(self.items)
def test_sixteen_bitflags(self): expected = [True, False] * 8 format = 'b' * len(expected) buf = dumps(format, expected) actual, _ = loads(format, buf) assert actual == expected
def test_bit_offset_adjusted_correctly(self): expected = [50, "quick", "fox", True, False, False, True, True, {"prop1": True}] buf = dumps('BssbbbbbF', expected) actual, _ = loads('BssbbbbbF', buf) assert actual == expected
def test_table(self): table = {'foo': 32, 'bar': 'baz', 'nil': None} assert loads(b'F', dumps(b'F', [table]))[0][0] == table
def test_loads_unknown_type(self): with pytest.raises(FrameSyntaxError): loads('x', 'asdsad')
def test_float(self): data = int(loads(b'fb', dumps(b'fb', [32.31, False]), 0)[0][0] * 100) assert (data == 3231)
def test_bit_offset_adjusted_correctly(self): expected = [50, "quick", "fox", True, False, False, True, True, {"prop1": True}] buf = dumps('BssbbbbbF', expected) actual, _ = loads('BssbbbbbF', buf, 0) assert actual == expected