本文整理汇总了Python中python_toolbox.sleek_reffing.CuteSleekValueDict.pop方法的典型用法代码示例。如果您正苦于以下问题:Python CuteSleekValueDict.pop方法的具体用法?Python CuteSleekValueDict.pop怎么用?Python CuteSleekValueDict.pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_toolbox.sleek_reffing.CuteSleekValueDict
的用法示例。
在下文中一共展示了CuteSleekValueDict.pop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pop
# 需要导入模块: from python_toolbox.sleek_reffing import CuteSleekValueDict [as 别名]
# 或者: from python_toolbox.sleek_reffing.CuteSleekValueDict import pop [as 别名]
def test_pop(self):
# Tests for pop with specified key
d = CuteSleekValueDict(null_callback)
k, v = 'abc', 'def'
d[k] = v
self.assertRaises(KeyError, d.pop, 'ghi')
self.assertEqual(d.pop(k), v)
self.assertEqual(len(d), 0)
self.assertRaises(KeyError, d.pop, k)
# verify longs/ints get same value when key > 32 bits
# (for 64-bit archs). See SF bug #689659. (MAKES NO SENSE ON PY3)
x = 4503599627370496
y = 4503599627370496
h = CuteSleekValueDict(
null_callback,
{x: 'anything', y: 'something else'}
)
self.assertEqual(h[x], h[y])
self.assertEqual(d.pop(k, v), v)
d[k] = v
self.assertEqual(d.pop(k, 1), v)
self.assertRaises(TypeError, d.pop)
class Exc(Exception): pass
class BadHash(object):
fail = False
def __hash__(self):
if self.fail:
raise Exc()
else:
return 42
x = BadHash()
d[x] = 42
x.fail = True
self.assertRaises(Exc, d.pop, x)