示例#1
0
 def test_encode_str(self):
     self.assertTrue(
         rencode.dumps(b"f" * 255) == rencode_orig.dumps(b"f" * 255) ==
         q_dumps(b"f" * 255))
     self.assertTrue(
         rencode.dumps(b"\0") == rencode_orig.dumps(b"\0") == q_dumps(b"\0")
     )
示例#2
0
 def test_encode_int_long_long_size(self):
     self.assertTrue(
         rencode.dumps(8223372036854775808) == rencode_orig.dumps(
             8223372036854775808) == q_dumps(8223372036854775808))
     self.assertTrue(
         rencode.dumps(-8223372036854775808) == rencode_orig.dumps(
             -8223372036854775808) == q_dumps(-8223372036854775808))
示例#3
0
 def test_encode_int_int_size(self):
     self.assertTrue(
         rencode.dumps(7483648) == rencode_orig.dumps(7483648) == q_dumps(
             7483648))
     self.assertTrue(
         rencode.dumps(-7483648) == rencode_orig.dumps(-7483648) == q_dumps(
             -7483648))
示例#4
0
 def test_encode_int_short_size(self):
     self.assertTrue(
         rencode.dumps(27123) == rencode_orig.dumps(27123) == q_dumps(27123)
     )
     self.assertTrue(
         rencode.dumps(-27123) == rencode_orig.dumps(-27123) == q_dumps(
             -27123))
示例#5
0
 def test_encode_int_char_size(self):
     self.assertTrue(
         rencode.dumps(100) == rencode_orig.dumps(100) == q_dumps(100))
     self.assertTrue(
         rencode.dumps(-100) == rencode_orig.dumps(-100) == q_dumps(-100))
示例#6
0
 def test_encode_fixed_str(self):
     self.assertEqual(rencode.dumps(b"foobarbaz"),
                      rencode_orig.dumps(b"foobarbaz"))
示例#7
0
 def test_encode_int_long_long_size(self):
     self.assertEqual(rencode.dumps(8223372036854775808),
                      rencode_orig.dumps(8223372036854775808))
     self.assertEqual(rencode.dumps(-8223372036854775808),
                      rencode_orig.dumps(-8223372036854775808))
示例#8
0
 def test_encode_fixed_neg_int(self):
     self.assertEqual(rencode.dumps(-10), rencode_orig.dumps(-10))
     self.assertEqual(rencode.dumps(-29), rencode_orig.dumps(-29))
示例#9
0
 def test_encode_list(self):
     l = [100, -234.01, b"foobar", u("bäz")] * 80
     self.assertEqual(rencode.dumps(l), rencode_orig.dumps(l))
示例#10
0
def test_encode_int_long_long_size_orig():
    rencode_orig.dumps(8223372036854775808)
    rencode_orig.dumps(-8223372036854775808)
示例#11
0
def test_encode_fixed_neg_int_orig():
    rencode_orig.dumps(-29)
示例#12
0
 def test_encode_unicode(self):
     self.assertTrue(
         rencode.dumps(u("fööbar")) == rencode_orig.dumps(u("fööbar")) ==
         q_dumps(u("fööbar")))
示例#13
0
 def test_encode_fixed_str(self):
     self.assertTrue(
         rencode.dumps(b"foobarbaz") == rencode_orig.dumps(b"foobarbaz") ==
         q_dumps(b"foobarbaz"))
示例#14
0
 def test_encode_float_64bit(self):
     self.assertTrue(
         rencode.dumps(1234.56, 64) == rencode_orig.dumps(1234.56, 64) ==
         q_dumps(1234.56, 64))
示例#15
0
def test_encode_fixed_dict_orig():
    rencode_orig.dumps(d)
示例#16
0
 def test_encode_none(self):
     self.assertTrue(
         rencode.dumps(None) == rencode_orig.dumps(None) == q_dumps(None))
示例#17
0
def test_overall_encode_orig():
    rencode_orig.dumps(overall)
示例#18
0
 def test_encode_bool(self):
     self.assertTrue(
         rencode.dumps(True) == rencode_orig.dumps(True) == q_dumps(True))
     self.assertTrue(
         rencode.dumps(False) == rencode_orig.dumps(False) == q_dumps(False)
     )
示例#19
0
def test_encode_int_short_size_orig():
    rencode_orig.dumps(27123)
    rencode_orig.dumps(-27123)
示例#20
0
 def test_encode_list(self):
     l = [100, -234.01, b"foobar", u("bäz")] * 80
     self.assertTrue(
         rencode.dumps(l) == rencode_orig.dumps(l) == q_dumps(l))
示例#21
0
def test_encode_float_32bit_orig():
    rencode_orig.dumps(1234.56)
示例#22
0
 def test_encode_fixed_pos_int(self):
     self.assertTrue(
         rencode.dumps(1) == rencode_orig.dumps(1) == q_dumps(1))
     self.assertTrue(
         rencode.dumps(40) == rencode_orig.dumps(40) == q_dumps(40))
示例#23
0
 def test_encode_dict(self):
     s = b"abcdefghijklmnopqrstuvwxyz1234567890"
     d = dict(zip(s, [1234] * len(s)))
     self.assertEqual(rencode.dumps(d), rencode_orig.dumps(d))
示例#24
0
 def test_encode_int_big_number(self):
     n = int("9"*62)
     self.assertEqual(rencode.dumps(n), rencode_orig.dumps(n))
     self.assertRaises(ValueError, rencode.dumps, int("9"*65))
示例#25
0
 def test_encode_int_short_size(self):
     self.assertEqual(rencode.dumps(27123), rencode_orig.dumps(27123))
     self.assertEqual(rencode.dumps(-27123), rencode_orig.dumps(-27123))
示例#26
0
 def test_encode_float_32bit(self):
     self.assertEqual(rencode.dumps(1234.56), rencode_orig.dumps(1234.56))
示例#27
0
 def test_encode_float_32bit(self):
     self.assertEqual(rencode.dumps(1234.56), rencode_orig.dumps(1234.56))
示例#28
0
 def test_encode_float_64bit(self):
     self.assertEqual(rencode.dumps(1234.56, 64), rencode_orig.dumps(1234.56, 64))
示例#29
0
 def test_encode_unicode(self):
     self.assertEqual(rencode.dumps(u("fööbar")),
                      rencode_orig.dumps(u("fööbar")))
示例#30
0
 def test_encode_fixed_str(self):
     self.assertEqual(rencode.dumps("foobarbaz"), rencode_orig.dumps("foobarbaz"))
示例#31
0
def test_encode_list_orig():
    rencode_orig.dumps(ll)
示例#32
0
 def test_encode_str(self):
     self.assertEqual(rencode.dumps("f"*255), rencode_orig.dumps("f"*255))
示例#33
0
def test_encode_dict_orig():
    rencode_orig.dumps(d2)
示例#34
0
 def test_encode_unicode(self):
     self.assertEqual(rencode.dumps(u"fööbar"), rencode_orig.dumps(u"fööbar"))
示例#35
0
def test_encode_fixed_pos_int_orig():
    rencode_orig.dumps(40)
示例#36
0
 def test_encode_none(self):
     self.assertEqual(rencode.dumps(None), rencode_orig.dumps(None))
示例#37
0
def test_encode_int_char_size_orig():
    rencode_orig.dumps(100)
    rencode_orig.dumps(-100)
示例#38
0
 def test_encode_bool(self):
     self.assertEqual(rencode.dumps(True), rencode_orig.dumps(True))
     self.assertEqual(rencode.dumps(False), rencode_orig.dumps(False))
示例#39
0
def test_encode_int_int_size_orig():
    rencode_orig.dumps(7483648)
    rencode_orig.dumps(-7483648)
示例#40
0
 def test_encode_list(self):
     l = [100, -234.01, "foobar", u"bäz"]*80
     self.assertEqual(rencode.dumps(l), rencode_orig.dumps(l))
示例#41
0
def test_encode_int_big_number_orig():
    rencode_orig.dumps(bn)
示例#42
0
 def test_encode_fixed_dict(self):
     s = "abcdefghijk"
     d = dict(zip(s, [1234]*len(s)))
     self.assertEqual(rencode.dumps(d), rencode_orig.dumps(d))
示例#43
0
 def test_encode_bool(self):
     self.assertEqual(rencode.dumps(True), rencode_orig.dumps(True))
     self.assertEqual(rencode.dumps(False), rencode_orig.dumps(False))
示例#44
0
 def test_encode_dict(self):
     s = "abcdefghijklmnopqrstuvwxyz1234567890"
     d = dict(zip(s, [1234]*len(s)))
     self.assertEqual(rencode.dumps(d), rencode_orig.dumps(d))
示例#45
0
 def test_encode_fixed_dict(self):
     s = b"abcdefghijk"
     d = dict(zip(s, [1234] * len(s)))
     self.assertEqual(rencode.dumps(d), rencode_orig.dumps(d))
示例#46
0
    -7483648,
    8223372036854775808,
    -8223372036854775808,
    int("9"*62),
    1227688834.643409,
    None,
    True
]

def test_overall_encode():
    rencode.dumps(overall)

def test_overall_encode_orig():
    rencode_orig.dumps(overall)

overall_decode_str = rencode_orig.dumps(overall)

def test_overall_decode():
    rencode.loads(overall_decode_str)

def test_overall_decode_orig():
    rencode_orig.loads(overall_decode_str)


if __name__ == "__main__":
    import timeit

    iterations = 10000
    # ANSI escape codes
    CSI="\x1B["
    reset=CSI+"m"
示例#47
0
 def test_encode_fixed_pos_int(self):
     self.assertEqual(rencode.dumps(1), rencode_orig.dumps(1))
     self.assertEqual(rencode.dumps(40), rencode_orig.dumps(40))
示例#48
0
def test_encode_float_64bit_orig():
    rencode_orig.dumps(1234.56, 64)
示例#49
0
 def test_encode_int_char_size(self):
     self.assertEqual(rencode.dumps(100), rencode_orig.dumps(100))
     self.assertEqual(rencode.dumps(-100), rencode_orig.dumps(-100))
示例#50
0
def test_encode_fixed_str_orig():
    rencode_orig.dumps(b"foobarbaz")
示例#51
0
 def test_encode_int_int_size(self):
     self.assertEqual(rencode.dumps(7483648), rencode_orig.dumps(7483648))
     self.assertEqual(rencode.dumps(-7483648), rencode_orig.dumps(-7483648))
示例#52
0
def test_encode_str_orig():
    rencode_orig.dumps(s)
示例#53
0
 def test_encode_int_big_number(self):
     n = int("9" * 62)
     self.assertEqual(rencode.dumps(n), rencode_orig.dumps(n))
     self.assertRaises(ValueError, rencode.dumps, int("9" * 65))
示例#54
0
def test_encode_none_orig():
    rencode_orig.dumps(None)
示例#55
0
 def test_encode_float_64bit(self):
     self.assertEqual(rencode.dumps(1234.56, 64),
                      rencode_orig.dumps(1234.56, 64))
示例#56
0
def test_encode_bool_orig():
    rencode_orig.dumps(True)
示例#57
0
 def test_encode_str(self):
     self.assertEqual(rencode.dumps(b"f" * 255),
                      rencode_orig.dumps(b"f" * 255))
     self.assertEqual(rencode.dumps(b"\0"), rencode_orig.dumps(b"\0"))
示例#58
0
def test_encode_fixed_list_orig():
    rencode_orig.dumps(l)
示例#59
0
 def test_encode_none(self):
     self.assertEqual(rencode.dumps(None), rencode_orig.dumps(None))
示例#60
0
 def test_encode_fixed_neg_int(self):
     self.assertTrue(
         rencode.dumps(-10) == rencode_orig.dumps(-10) == q_dumps(-10))
     self.assertTrue(
         rencode.dumps(-29) == rencode_orig.dumps(-29) == q_dumps(-29))