本文整理汇总了Python中tests.utils.helpers.TestStore.get方法的典型用法代码示例。如果您正苦于以下问题:Python TestStore.get方法的具体用法?Python TestStore.get怎么用?Python TestStore.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.utils.helpers.TestStore
的用法示例。
在下文中一共展示了TestStore.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_distribute_with_ignore_result_set
# 需要导入模块: from tests.utils.helpers import TestStore [as 别名]
# 或者: from tests.utils.helpers.TestStore import get [as 别名]
def test_distribute_with_ignore_result_set(self):
"""
The specified number of subtasks is actually spawned even for tasks
with ignore_result=True and these run and complete.
Since the results of the tasks are ignored, the only way to know that
they ran and completed is to verify that the data they were supposed
to write the key value store is actually there.
"""
def value(key):
"""Construct a test value for the given key."""
return key[-3:] * 2
keys = ["irtc:%s" % str(uuid.uuid4())[:8] for _ in xrange(5)]
values = [value(uid) for uid in keys]
data = zip(keys, values)
result = tasks.distribute(ignore_result, ("data", [[d] for d in data]))
# An empty list is returned for tasks with ignore_result=True
# and no asynchronous task handler function.
self.assertEqual(False, bool(result))
# Give the tasks a bit of time to complete.
time.sleep(0.1)
for key, value in data:
self.assertEqual(value, TestStore.get(key))
示例2: ath
# 需要导入模块: from tests.utils.helpers import TestStore [as 别名]
# 或者: from tests.utils.helpers.TestStore import get [as 别名]
def ath(data):
"""
An asynchronous task handler function that converts all task
results to upper case and returns the list of keys found.
"""
items_expected = len(data)
items_found = []
while len(items_found) < items_expected:
for key, _ in data:
if key in items_found:
continue
value = TestStore.get(key)
if value is not None:
TestStore.set(key, value.upper())
items_found.append(key)
time.sleep(0.05)
return items_found
示例3: test_distribute_with_ignore_result_set_and_ath
# 需要导入模块: from tests.utils.helpers import TestStore [as 别名]
# 或者: from tests.utils.helpers.TestStore import get [as 别名]
def test_distribute_with_ignore_result_set_and_ath(self):
"""
The specified number of subtasks is actually spawned (even for tasks
with ignore_result=True) and the asynchronous task handler function is
run.
"""
def value(key):
"""Construct a test value for the given key."""
return key[-3:] * 2
def ath(data):
"""
An asynchronous task handler function that converts all task
results to upper case and returns the list of keys found.
"""
items_expected = len(data)
items_found = []
while len(items_found) < items_expected:
for key, _ in data:
if key in items_found:
continue
value = TestStore.get(key)
if value is not None:
TestStore.set(key, value.upper())
items_found.append(key)
time.sleep(0.05)
return items_found
keys = ["irtc:%s" % str(uuid.uuid4())[:8] for _ in xrange(5)]
values = [value(uid) for uid in keys]
data = zip(keys, values)
args = ("data", [[d] for d in data])
result = tasks.distribute(ignore_result, args, ath=ath,
ath_args=dict(data=data))
self.assertEqual(sorted(keys), sorted(result))
for key, value in data:
self.assertEqual(value.upper(), TestStore.get(key))