本文整理汇总了Python中mozbuild.frontend.context.Context.keys方法的典型用法代码示例。如果您正苦于以下问题:Python Context.keys方法的具体用法?Python Context.keys怎么用?Python Context.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozbuild.frontend.context.Context
的用法示例。
在下文中一共展示了Context.keys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update
# 需要导入模块: from mozbuild.frontend.context import Context [as 别名]
# 或者: from mozbuild.frontend.context.Context import keys [as 别名]
def test_update(self):
test = Context({"foo": (int, int, "", None), "bar": (bool, bool, "", None), "baz": (dict, list, "", None)})
self.assertEqual(test.keys(), [])
with self.assertRaises(ValueError):
test.update(bar=True, foo={})
self.assertEqual(test.keys(), [])
test.update(bar=True, foo=1)
self.assertEqual(set(test.keys()), {"foo", "bar"})
self.assertEqual(test["foo"], 1)
self.assertEqual(test["bar"], True)
test.update([("bar", False), ("foo", 2)])
self.assertEqual(test["foo"], 2)
self.assertEqual(test["bar"], False)
test.update([("foo", 0), ("baz", {"a": 1, "b": 2})])
self.assertEqual(test["foo"], 0)
self.assertEqual(test["baz"], {"a": 1, "b": 2})
test.update([("foo", 42), ("baz", [("c", 3), ("d", 4)])])
self.assertEqual(test["foo"], 42)
self.assertEqual(test["baz"], {"c": 3, "d": 4})
示例2: test_update
# 需要导入模块: from mozbuild.frontend.context import Context [as 别名]
# 或者: from mozbuild.frontend.context.Context import keys [as 别名]
def test_update(self):
test = Context({
'foo': (int, int, '', None),
'bar': (bool, bool, '', None),
'baz': (dict, list, '', None),
})
self.assertEqual(test.keys(), [])
with self.assertRaises(ValueError):
test.update(bar=True, foo={})
self.assertEqual(test.keys(), [])
test.update(bar=True, foo=1)
self.assertEqual(set(test.keys()), { 'foo', 'bar' })
self.assertEqual(test['foo'], 1)
self.assertEqual(test['bar'], True)
test.update([('bar', False), ('foo', 2)])
self.assertEqual(test['foo'], 2)
self.assertEqual(test['bar'], False)
test.update([('foo', 0), ('baz', { 'a': 1, 'b': 2 })])
self.assertEqual(test['foo'], 0)
self.assertEqual(test['baz'], { 'a': 1, 'b': 2 })
test.update([('foo', 42), ('baz', [('c', 3), ('d', 4)])])
self.assertEqual(test['foo'], 42)
self.assertEqual(test['baz'], { 'c': 3, 'd': 4 })
示例3: test_defaults
# 需要导入模块: from mozbuild.frontend.context import Context [as 别名]
# 或者: from mozbuild.frontend.context.Context import keys [as 别名]
def test_defaults(self):
test = Context({
'foo': (int, int, '', None),
'bar': (bool, bool, '', None),
'baz': (dict, dict, '', None),
})
self.assertEqual(test.keys(), [])
self.assertEqual(test['foo'], 0)
self.assertEqual(set(test.keys()), { 'foo' })
self.assertEqual(test['bar'], False)
self.assertEqual(set(test.keys()), { 'foo', 'bar' })
self.assertEqual(test['baz'], {})
self.assertEqual(set(test.keys()), { 'foo', 'bar', 'baz' })
with self.assertRaises(KeyError):
test['qux']
self.assertEqual(set(test.keys()), { 'foo', 'bar', 'baz' })
示例4: test_defaults
# 需要导入模块: from mozbuild.frontend.context import Context [as 别名]
# 或者: from mozbuild.frontend.context.Context import keys [as 别名]
def test_defaults(self):
test = Context({"foo": (int, int, "", None), "bar": (bool, bool, "", None), "baz": (dict, dict, "", None)})
self.assertEqual(test.keys(), [])
self.assertEqual(test["foo"], 0)
self.assertEqual(set(test.keys()), {"foo"})
self.assertEqual(test["bar"], False)
self.assertEqual(set(test.keys()), {"foo", "bar"})
self.assertEqual(test["baz"], {})
self.assertEqual(set(test.keys()), {"foo", "bar", "baz"})
with self.assertRaises(KeyError):
test["qux"]
self.assertEqual(set(test.keys()), {"foo", "bar", "baz"})