本文整理匯總了Python中celery.datastructures.ConfigurationView.get方法的典型用法代碼示例。如果您正苦於以下問題:Python ConfigurationView.get方法的具體用法?Python ConfigurationView.get怎麽用?Python ConfigurationView.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類celery.datastructures.ConfigurationView
的用法示例。
在下文中一共展示了ConfigurationView.get方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_ConfigurationView
# 需要導入模塊: from celery.datastructures import ConfigurationView [as 別名]
# 或者: from celery.datastructures.ConfigurationView import get [as 別名]
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())
示例2: test_ConfigurationView
# 需要導入模塊: from celery.datastructures import ConfigurationView [as 別名]
# 或者: from celery.datastructures.ConfigurationView import get [as 別名]
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()),
)
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))
示例3: test_ConfigurationView
# 需要導入模塊: from celery.datastructures import ConfigurationView [as 別名]
# 或者: from celery.datastructures.ConfigurationView import get [as 別名]
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))
示例4: test_ConfigurationView
# 需要導入模塊: from celery.datastructures import ConfigurationView [as 別名]
# 或者: from celery.datastructures.ConfigurationView import get [as 別名]
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))