本文整理汇总了Python中python_toolbox.sleek_reffing.CuteSleekValueDict.copy方法的典型用法代码示例。如果您正苦于以下问题:Python CuteSleekValueDict.copy方法的具体用法?Python CuteSleekValueDict.copy怎么用?Python CuteSleekValueDict.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_toolbox.sleek_reffing.CuteSleekValueDict
的用法示例。
在下文中一共展示了CuteSleekValueDict.copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_popitem
# 需要导入模块: from python_toolbox.sleek_reffing import CuteSleekValueDict [as 别名]
# 或者: from python_toolbox.sleek_reffing.CuteSleekValueDict import copy [as 别名]
def test_popitem(self):
if sys_tools.is_pypy:
raise nose.SkipTest("Pypy doesn't maintain dict order.")
for copymode in -1, +1:
# -1: b has same structure as a
# +1: b is a.copy()
for log2size in range(12):
size = 2**log2size
a = CuteSleekValueDict(null_callback)
b = CuteSleekValueDict(null_callback)
for i in range(size):
a[repr(i)] = i
if copymode < 0:
b[repr(i)] = i
if copymode > 0:
b = a.copy()
for i in range(size):
ka, va = ta = a.popitem()
self.assertEqual(va, int(ka))
kb, vb = tb = b.popitem()
self.assertEqual(vb, int(kb))
if copymode < 0:
self.assertEqual(ta, tb)
self.assertFalse(a)
self.assertFalse(b)
d = CuteSleekValueDict(null_callback)
self.assertRaises(KeyError, d.popitem)
示例2: test_copy
# 需要导入模块: from python_toolbox.sleek_reffing import CuteSleekValueDict [as 别名]
# 或者: from python_toolbox.sleek_reffing.CuteSleekValueDict import copy [as 别名]
def test_copy(self):
d = CuteSleekValueDict(null_callback, {1: 1, 2: 2, 3: 3})
self.assertEqual(
d.copy(),
CuteSleekValueDict(null_callback, {1: 1, 2: 2, 3: 3})
)
self.assertEqual(
CuteSleekValueDict(null_callback).copy(),
CuteSleekValueDict(null_callback)
)
self.assertRaises(TypeError, d.copy, None)