def test_roundtrip_format_examples(self):
     for data, expect in FORMAT_EXAMPLES.items():
         self.assertEqual(expect, tnetstring.loads(data))
         self.assertEqual(expect,
                          tnetstring.loads(tnetstring.dumps(expect)))
         self.assertEqual((expect, b''), tnetstring.pop(data))
 def test_roundtrip_format_unicode(self):
     for _ in range(500):
         v = get_random_object()
         self.assertEqual(v, tnetstring.loads(tnetstring.dumps(v)))
         self.assertEqual((v, b''), tnetstring.pop(tnetstring.dumps(v)))
 def test_roundtrip_big_integer(self):
     i1 = math.factorial(30000)
     s = tnetstring.dumps(i1)
     i2 = tnetstring.loads(s)
     self.assertEqual(i1, i2)
 def test_roundtrip_big_integer(self):
     i1 = math.factorial(30000)
     s = tnetstring.dumps(i1)
     i2 = tnetstring.loads(s)
     self.assertEqual(i1, i2)
 def test_roundtrip_format_unicode(self):
     for _ in range(500):
         v = get_random_object()
         self.assertEqual(v, tnetstring.loads(tnetstring.dumps(v)))
         self.assertEqual((v, b''), tnetstring.pop(tnetstring.dumps(v)))
 def test_roundtrip_format_examples(self):
     for data, expect in FORMAT_EXAMPLES.items():
         self.assertEqual(expect, tnetstring.loads(data))
         self.assertEqual(
             expect, tnetstring.loads(tnetstring.dumps(expect)))
         self.assertEqual((expect, b''), tnetstring.pop(data))
 def test_unicode_handling(self):
     with self.assertRaises(ValueError):
         tnetstring.dumps(u"hello")
     self.assertEqual(tnetstring.dumps(u"hello".encode()), b"5:hello,")
     self.assertEqual(type(tnetstring.loads(b"5:hello,")), bytes)