Exemplo n.º 1
0
 def test_ping_result_message_decode(self):
     """
     This is an example message received from an actual ping server. Let's
     try to make sense of it.
     """
     repsonse = b'ds8:messagesb1;'  # As returned by the "requests" lib
     result = bpickle.loads(repsonse)
     expected = {"messages": True}
     self.assertEqual(expected, result)
Exemplo n.º 2
0
    def test_real_registration_answer_loading(self):
        """ We succeed at decoding a real-world example."""
        expected = {
            'server-api':
            '3.3',
            'server-uuid':
            'server-uuid',
            'messages': [{
                'types': ['register', 'test'],
                'type': 'accepted-types'
            }, {
                'id': 'secure-id',
                'insecure-id': 999999,
                'type': 'set-id'
            }]
        }

        result = bpickle.loads(REAL_ANSWER)
        self.assertEqual(expected, result)
Exemplo n.º 3
0
 def test_long(self):
     long = 99999999999999999999999999999
     self.assertEqual(bpickle.loads(bpickle.dumps(long)), long)
Exemplo n.º 4
0
 def test_bool(self):
     self.assertEqual(bpickle.loads(bpickle.dumps(True)), True)
Exemplo n.º 5
0
 def test_dict(self):
     dumped_tostr = bpickle.dumps({True: "hello"})
     self.assertEqual(bpickle.loads(dumped_tostr), {True: "hello"})
     dumped_tobool = bpickle.dumps({True: False})
     self.assertEqual(bpickle.loads(dumped_tobool), {True: False})
Exemplo n.º 6
0
 def test_none(self):
     self.assertEqual(bpickle.loads(bpickle.dumps(None)), None)
Exemplo n.º 7
0
 def test_unicode(self):
     self.assertEqual(bpickle.loads(bpickle.dumps(u'\xc0')), u'\xc0')
Exemplo n.º 8
0
 def test_inverted_lists(self, l):
     assert bpickle.loads(bpickle.dumps(l)) == l
Exemplo n.º 9
0
 def test_tuple(self):
     data = bpickle.dumps((1, [], 2, 'hello', 3.0))
     self.assertEqual(bpickle.loads(data), (1, [], 2, 'hello', 3.0))
Exemplo n.º 10
0
 def test_list(self):
     self.assertEqual(bpickle.loads(bpickle.dumps([1, 2, 'hello', 3.0])),
                      [1, 2, 'hello', 3.0])
Exemplo n.º 11
0
 def test_string(self, s):
     assert bpickle.loads(bpickle.dumps(s)) == s
Exemplo n.º 12
0
 def test_float_scientific_notation(self):
     number = 0.00005
     self.assertTrue("e" in repr(number))
     self.assertAlmostEquals(bpickle.loads(bpickle.dumps(number)), number)
Exemplo n.º 13
0
 def test_float(self):
     self.assertAlmostEquals(bpickle.loads(bpickle.dumps(2.3)), 2.3)
Exemplo n.º 14
0
 def test_int(self, i):
     assert bpickle.loads(bpickle.dumps(i)) == i