当前位置: 首页>>代码示例>>Python>>正文


Python pickle.INT属性代码示例

本文整理汇总了Python中pickle.INT属性的典型用法代码示例。如果您正苦于以下问题:Python pickle.INT属性的具体用法?Python pickle.INT怎么用?Python pickle.INT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在pickle的用法示例。


在下文中一共展示了pickle.INT属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_singletons

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import INT [as 别名]
def test_singletons(self):
        # Map (proto, singleton) to expected opcode.
        expected_opcode = {(0, None): pickle.NONE,
                           (1, None): pickle.NONE,
                           (2, None): pickle.NONE,

                           (0, True): pickle.INT,
                           (1, True): pickle.INT,
                           (2, True): pickle.NEWTRUE,

                           (0, False): pickle.INT,
                           (1, False): pickle.INT,
                           (2, False): pickle.NEWFALSE,
                          }
        for proto in protocols:
            for x in None, False, True:
                s = self.dumps(x, proto)
                y = self.loads(s)
                self.assertTrue(x is y, (proto, x, s, y))
                expected = expected_opcode[proto, x]
                self.assertEqual(opcode_in_pickle(expected, s), True) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:pickletester.py

示例2: test_singletons

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import INT [as 别名]
def test_singletons(self):
        # Map (proto, singleton) to expected opcode.
        expected_opcode = {(0, None): pickle.NONE,
                           (1, None): pickle.NONE,
                           (2, None): pickle.NONE,
                           (3, None): pickle.NONE,

                           (0, True): pickle.INT,
                           (1, True): pickle.INT,
                           (2, True): pickle.NEWTRUE,
                           (3, True): pickle.NEWTRUE,

                           (0, False): pickle.INT,
                           (1, False): pickle.INT,
                           (2, False): pickle.NEWFALSE,
                           (3, False): pickle.NEWFALSE,
                          }
        for proto in protocols:
            for x in None, False, True:
                s = self.dumps(x, proto)
                y = self.loads(s)
                self.assertTrue(x is y, (proto, x, s, y))
                expected = expected_opcode[min(proto, 3), x]
                self.assertTrue(opcode_in_pickle(expected, s)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:26,代码来源:pickletester.py

示例3: test_singletons

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import INT [as 别名]
def test_singletons(self):
        # Map (proto, singleton) to expected opcode.
        expected_opcode = {(0, None): pickle.NONE,
                           (1, None): pickle.NONE,
                           (2, None): pickle.NONE,

                           (0, True): pickle.INT,
                           (1, True): pickle.INT,
                           (2, True): pickle.NEWTRUE,

                           (0, False): pickle.INT,
                           (1, False): pickle.INT,
                           (2, False): pickle.NEWFALSE,
                          }
        for proto in protocols:
            for x in None, False, True:
                s = self.dumps(x, proto)
                y = self.loads(s)
                self.assert_(x is y, (proto, x, s, y))
                expected = expected_opcode[proto, x]
                self.assertEqual(opcode_in_pickle(expected, s), True) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:23,代码来源:pickletester.py

示例4: test_simple_newobj

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import INT [as 别名]
def test_simple_newobj(self):
        x = SimpleNewObj.__new__(SimpleNewObj, 0xface)  # avoid __init__
        x.abc = 666
        for proto in protocols:
            s = self.dumps(x, proto)
            if proto < 1:
                self.assertIn('\nI64206', s)  # INT
            else:
                self.assertIn('M\xce\xfa', s)  # BININT2
            self.assertEqual(opcode_in_pickle(pickle.NEWOBJ, s), proto >= 2)
            y = self.loads(s)   # will raise TypeError if __init__ called
            self.assertEqual(y.abc, 666)
            self.assertEqual(x.__dict__, y.__dict__) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:pickletester.py

示例5: test_complex_newobj

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import INT [as 别名]
def test_complex_newobj(self):
        x = ComplexNewObj.__new__(ComplexNewObj, 0xface)  # avoid __init__
        x.abc = 666
        for proto in protocols:
            s = self.dumps(x, proto)
            if proto < 1:
                self.assertIn('\nI64206', s)  # INT
            elif proto < 2:
                self.assertIn('M\xce\xfa', s)  # BININT2
            else:
                self.assertIn('U\x04FACE', s)  # SHORT_BINSTRING
            self.assertEqual(opcode_in_pickle(pickle.NEWOBJ, s), proto >= 2)
            y = self.loads(s)   # will raise TypeError if __init__ called
            self.assertEqual(y.abc, 666)
            self.assertEqual(x.__dict__, y.__dict__) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:pickletester.py

示例6: test_frame_readline

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import INT [as 别名]
def test_frame_readline(self):
        pickled = b'\x80\x04\x95\x05\x00\x00\x00\x00\x00\x00\x00I42\n.'
        #    0: \x80 PROTO      4
        #    2: \x95 FRAME      5
        #   11: I    INT        42
        #   15: .    STOP
        self.assertEqual(self.loads(pickled), 42) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:pickletester.py


注:本文中的pickle.INT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。