本文整理汇总了Python中admit.AT.AT.setkey方法的典型用法代码示例。如果您正苦于以下问题:Python AT.setkey方法的具体用法?Python AT.setkey怎么用?Python AT.setkey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类admit.AT.AT
的用法示例。
在下文中一共展示了AT.setkey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_key
# 需要导入模块: from admit.AT import AT [as 别名]
# 或者: from admit.AT.AT import setkey [as 别名]
def test_key(self):
at = AT({'alias': 't', 'test_key': 'at_test'})
key = "test_key"
val = "TEST"
t1 = at.haskey("testtesttest") # invalid key
self.assertEqual(t1, False)
# test haskey()
t1 = at.haskey(key) # AT should have the key set at init
self.assertTrue(t1)
# test setkey()
at.setkey(name=key, value=val, isinit=True)
# test getkey()
ret = at.getkey(key)
if(self.verbose):
print "\n test key:", ret
self.assertEqual(ret, "TEST")
# test {key:val} way of setting a key
at.setkey(name={key:"TEST2"})
ret = at.getkey(key)
if(self.verbose):
print "\n alias key:", ret
self.assertEqual(ret, "TEST2")
示例2: test_AT_key
# 需要导入模块: from admit.AT import AT [as 别名]
# 或者: from admit.AT.AT import setkey [as 别名]
def test_AT_key(self):
""" test AT setkey(), getkey(), and haskey() """
at = AT({'alias': 't', 'test_key': 'at_test'})
key = "test_key"
# test invalid key
self.assertFalse(at.haskey("testtesttest"))
# test haskey()
# AT should have the key set at init
self.assertTrue(at.haskey(key))
# test setkey()
at.setkey(name=key, value="TEST", isinit=True)
# test getkey()
self.assertEqual(at.getkey(key), "TEST")
# test {key:val} way of setting a key
at.setkey(name={key:"TEST2"})
self.assertEqual(at.getkey(key), "TEST2")