def test_marshal_set(self): to_marshal = sortedset([]) self.assertEqual(marshal(to_marshal), '{}') # the order of elements in set might change to_marshal = sortedset([1, 2]) self.assertIn(marshal(to_marshal), {'{1, 2}', '{2, 1}'}) to_marshal = sortedset(['1', '2']) self.assertIn(marshal(to_marshal), {"{'1', '2'}", "{'2', '1'}"})
def test_unmarshal_set(self): marshalled_value_pairs = ( ('\x00\x00', INTEGER_TYPE, sortedset()), ('\x00\x01\x00\x04\x00\x00\x00\x05', INTEGER_TYPE, sortedset([5])), ('\x00\x02\x00\x01\x00\x00\x01\x01', BOOLEAN_TYPE, sortedset([False, True])) ) for marshalled, valtype, expected in marshalled_value_pairs: unmarshalled = unmarshal_set(valtype, marshalled) self.assertEqual(unmarshalled, expected)
def test_unmarshal_set(self): marshalled_value_pairs = (('\x00\x00', INTEGER_TYPE, sortedset()), ('\x00\x01\x00\x04\x00\x00\x00\x05', INTEGER_TYPE, sortedset([5])), ('\x00\x02\x00\x01\x00\x00\x01\x01', BOOLEAN_TYPE, sortedset([False, True]))) for marshalled, valtype, expected in marshalled_value_pairs: unmarshalled = unmarshal_set(valtype, marshalled) self.assertEqual(unmarshalled, expected)