本文整理汇总了Python中celery.datastructures.ConfigurationView类的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationView类的具体用法?Python ConfigurationView怎么用?Python ConfigurationView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigurationView类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ConfigurationView
class test_ConfigurationView(unittest.TestCase):
def setUp(self):
self.view = ConfigurationView({"changed_key": 1,
"both": 2},
[{"default_key": 1,
"both": 1}])
def test_setdefault(self):
self.assertEqual(self.view.setdefault("both", 36), 2)
self.assertEqual(self.view.setdefault("new", 36), 36)
def test_contains(self):
self.assertIn("changed_key", self.view)
self.assertIn("default_key", self.view)
self.assertNotIn("new", self.view)
def test_repr(self):
self.assertIn("changed_key", repr(self.view))
self.assertIn("default_key", repr(self.view))
def test_iter(self):
expected = {"changed_key": 1,
"default_key": 1,
"both": 2}
self.assertDictEqual(dict(self.view.items()), expected)
示例2: test_ConfigurationView
class test_ConfigurationView(Case):
def setUp(self):
self.view = ConfigurationView({"changed_key": 1, "both": 2}, [{"default_key": 1, "both": 1}])
def test_setdefault(self):
self.assertEqual(self.view.setdefault("both", 36), 2)
self.assertEqual(self.view.setdefault("new", 36), 36)
def test_get(self):
self.assertEqual(self.view.get("both"), 2)
sp = object()
self.assertIs(self.view.get("nonexisting", sp), sp)
def test_update(self):
changes = dict(self.view.changes)
self.view.update(a=1, b=2, c=3)
self.assertDictEqual(self.view.changes, dict(changes, a=1, b=2, c=3))
def test_contains(self):
self.assertIn("changed_key", self.view)
self.assertIn("default_key", self.view)
self.assertNotIn("new", self.view)
def test_repr(self):
self.assertIn("changed_key", repr(self.view))
self.assertIn("default_key", repr(self.view))
def test_iter(self):
expected = {"changed_key": 1, "default_key": 1, "both": 2}
self.assertDictEqual(dict(self.view.items()), expected)
self.assertItemsEqual(list(iter(self.view)), expected.keys())
self.assertItemsEqual(self.view.keys(), expected.keys())
self.assertItemsEqual(self.view.values(), expected.values())
示例3: test_ConfigurationView
class test_ConfigurationView(Case):
def setUp(self):
self.view = ConfigurationView({'changed_key': 1,
'both': 2},
[{'default_key': 1,
'both': 1}])
def test_setdefault(self):
self.assertEqual(self.view.setdefault('both', 36), 2)
self.assertEqual(self.view.setdefault('new', 36), 36)
def test_get(self):
self.assertEqual(self.view.get('both'), 2)
sp = object()
self.assertIs(self.view.get('nonexisting', sp), sp)
def test_update(self):
changes = dict(self.view.changes)
self.view.update(a=1, b=2, c=3)
self.assertDictEqual(self.view.changes,
dict(changes, a=1, b=2, c=3))
def test_contains(self):
self.assertIn('changed_key', self.view)
self.assertIn('default_key', self.view)
self.assertNotIn('new', self.view)
def test_repr(self):
self.assertIn('changed_key', repr(self.view))
self.assertIn('default_key', repr(self.view))
def test_iter(self):
expected = {'changed_key': 1,
'default_key': 1,
'both': 2}
self.assertDictEqual(dict(self.view.items()), expected)
self.assertItemsEqual(list(iter(self.view)),
expected.keys())
self.assertItemsEqual(self.view.keys(), expected.keys())
self.assertItemsEqual(self.view.values(), expected.values())
def test_isa_mapping(self):
from collections import Mapping
self.assertTrue(issubclass(ConfigurationView, Mapping))
def test_isa_mutable_mapping(self):
from collections import MutableMapping
self.assertTrue(issubclass(ConfigurationView, MutableMapping))
示例4: setUp
def setUp(self):
self.view = ConfigurationView({'changed_key': 1,
'both': 2},
[{'default_key': 1,
'both': 1}])
示例5: test_ConfigurationView
class test_ConfigurationView(Case):
def setUp(self):
self.view = ConfigurationView({'changed_key': 1,
'both': 2},
[{'default_key': 1,
'both': 1}])
def test_setdefault(self):
self.assertEqual(self.view.setdefault('both', 36), 2)
self.assertEqual(self.view.setdefault('new', 36), 36)
def test_get(self):
self.assertEqual(self.view.get('both'), 2)
sp = object()
self.assertIs(self.view.get('nonexisting', sp), sp)
def test_update(self):
changes = dict(self.view.changes)
self.view.update(a=1, b=2, c=3)
self.assertDictEqual(self.view.changes,
dict(changes, a=1, b=2, c=3))
def test_contains(self):
self.assertIn('changed_key', self.view)
self.assertIn('default_key', self.view)
self.assertNotIn('new', self.view)
def test_repr(self):
self.assertIn('changed_key', repr(self.view))
self.assertIn('default_key', repr(self.view))
def test_iter(self):
expected = {'changed_key': 1,
'default_key': 1,
'both': 2}
self.assertDictEqual(dict(items(self.view)), expected)
self.assertItemsEqual(list(iter(self.view)),
list(expected.keys()))
self.assertItemsEqual(list(self.view.keys()), list(expected.keys()))
self.assertItemsEqual(
list(self.view.values()),
list(expected.values()),
)
self.assertIn('changed_key', list(self.view.keys()))
self.assertIn(2, list(self.view.values()))
self.assertIn(('both', 2), list(self.view.items()))
def test_add_defaults_dict(self):
defaults = {'foo': 10}
self.view.add_defaults(defaults)
self.assertEqual(self.view.foo, 10)
def test_add_defaults_object(self):
defaults = Object()
defaults.foo = 10
self.view.add_defaults(defaults)
self.assertEqual(self.view.foo, 10)
def test_clear(self):
self.view.clear()
self.assertEqual(self.view.both, 1)
self.assertNotIn('changed_key', self.view)
def test_bool(self):
self.assertTrue(bool(self.view))
self.view._order[:] = []
self.assertFalse(bool(self.view))
def test_len(self):
self.assertEqual(len(self.view), 3)
self.view.KEY = 33
self.assertEqual(len(self.view), 4)
self.view.clear()
self.assertEqual(len(self.view), 2)
def test_isa_mapping(self):
from collections import Mapping
self.assertTrue(issubclass(ConfigurationView, Mapping))
def test_isa_mutable_mapping(self):
from collections import MutableMapping
self.assertTrue(issubclass(ConfigurationView, MutableMapping))
示例6: test_ConfigurationView
class test_ConfigurationView(Case):
def setUp(self):
self.view = ConfigurationView({"changed_key": 1, "both": 2}, [{"default_key": 1, "both": 1}])
def test_setdefault(self):
self.view.setdefault("both", 36)
self.assertEqual(self.view["both"], 2)
self.view.setdefault("new", 36)
self.assertEqual(self.view["new"], 36)
def test_get(self):
self.assertEqual(self.view.get("both"), 2)
sp = object()
self.assertIs(self.view.get("nonexisting", sp), sp)
def test_update(self):
changes = dict(self.view.changes)
self.view.update(a=1, b=2, c=3)
self.assertDictEqual(self.view.changes, dict(changes, a=1, b=2, c=3))
def test_contains(self):
self.assertIn("changed_key", self.view)
self.assertIn("default_key", self.view)
self.assertNotIn("new", self.view)
def test_repr(self):
self.assertIn("changed_key", repr(self.view))
self.assertIn("default_key", repr(self.view))
def test_iter(self):
expected = {"changed_key": 1, "default_key": 1, "both": 2}
self.assertDictEqual(dict(items(self.view)), expected)
self.assertItemsEqual(list(iter(self.view)), list(expected.keys()))
self.assertItemsEqual(list(self.view.keys()), list(expected.keys()))
self.assertItemsEqual(list(self.view.values()), list(expected.values()))
self.assertIn("changed_key", list(self.view.keys()))
self.assertIn(2, list(self.view.values()))
self.assertIn(("both", 2), list(self.view.items()))
def test_add_defaults_dict(self):
defaults = {"foo": 10}
self.view.add_defaults(defaults)
self.assertEqual(self.view.foo, 10)
def test_add_defaults_object(self):
defaults = Bunch(foo=10)
self.view.add_defaults(defaults)
self.assertEqual(self.view.foo, 10)
def test_clear(self):
self.view.clear()
self.assertEqual(self.view.both, 1)
self.assertNotIn("changed_key", self.view)
def test_bool(self):
self.assertTrue(bool(self.view))
self.view._order[:] = []
self.assertFalse(bool(self.view))
def test_len(self):
self.assertEqual(len(self.view), 3)
self.view.KEY = 33
self.assertEqual(len(self.view), 4)
self.view.clear()
self.assertEqual(len(self.view), 2)
def test_isa_mapping(self):
from collections import Mapping
self.assertTrue(issubclass(ConfigurationView, Mapping))
def test_isa_mutable_mapping(self):
from collections import MutableMapping
self.assertTrue(issubclass(ConfigurationView, MutableMapping))