本文整理汇总了Python中background_task.tasks.tasks.background函数的典型用法代码示例。如果您正苦于以下问题:Python background函数的具体用法?Python background怎么用?Python background使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了background函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_proxy
def test_get_proxy(self):
proxy = tasks.background()(empty_task)
self.assertNotEqual(proxy, empty_task)
self.assertTrue(isinstance(proxy, TaskProxy))
# and alternate form
proxy = tasks.background(empty_task)
self.assertNotEqual(proxy, empty_task)
self.assertTrue(isinstance(proxy, TaskProxy))
开发者ID:Zagrebelin,项目名称:django-background-tasks,代码行数:9,代码来源:task_tests.py
示例2: test_default_name
def test_default_name(self):
proxy = tasks.background()(empty_task)
self.assertEqual(proxy.name, 'background_task.tests.task_tests.empty_task')
proxy = tasks.background()(record_task)
self.assertEqual(proxy.name, 'background_task.tests.task_tests.record_task')
proxy = tasks.background(empty_task)
# print proxy
self.assertTrue(isinstance(proxy, TaskProxy))
self.assertEqual(proxy.name, 'background_task.tests.task_tests.empty_task')
开发者ID:Zagrebelin,项目名称:django-background-tasks,代码行数:11,代码来源:task_tests.py
示例3: setUp
def setUp(self):
super(TestTaskProxy, self).setUp()
self.proxy = tasks.background()(record_task)
开发者ID:Zagrebelin,项目名称:django-background-tasks,代码行数:3,代码来源:task_tests.py
示例4: test__unicode__
def test__unicode__(self):
proxy = tasks.background()(empty_task)
self.assertEqual(u'TaskProxy(background_task.tests.task_tests.empty_task)',
unicode(proxy))
开发者ID:Zagrebelin,项目名称:django-background-tasks,代码行数:4,代码来源:task_tests.py
示例5: test_schedule
def test_schedule(self):
proxy = tasks.background(schedule=10)(empty_task)
self.assertEqual(TaskSchedule(run_at=10), proxy.schedule)
开发者ID:Zagrebelin,项目名称:django-background-tasks,代码行数:3,代码来源:task_tests.py
示例6: test_default_schedule
def test_default_schedule(self):
proxy = tasks.background()(empty_task)
self.assertEqual(TaskSchedule(), proxy.schedule)
开发者ID:Zagrebelin,项目名称:django-background-tasks,代码行数:3,代码来源:task_tests.py
示例7: test_task_function
def test_task_function(self):
proxy = tasks.background()(empty_task)
self.assertEqual(proxy.task_function, empty_task)
proxy = tasks.background()(record_task)
self.assertEqual(proxy.task_function, record_task)
开发者ID:Zagrebelin,项目名称:django-background-tasks,代码行数:6,代码来源:task_tests.py
示例8: test_specified_name
def test_specified_name(self):
proxy = tasks.background(name='mytask')(empty_task)
self.assertEqual(proxy.name, 'mytask')
开发者ID:Zagrebelin,项目名称:django-background-tasks,代码行数:3,代码来源:task_tests.py
示例9: test__unicode__
def test__unicode__(self): proxy = tasks.background()(empty_task) self.assertEqual(u'TaskProxy(background_task.tests.empty_task)', unicode(proxy)) def test_shortcut(self): '''check shortcut to decorator works''' proxy = background()(empty_task) self.failIfEqual(proxy, empty_task) self.assertEqual(proxy.task_function, empty_task)
开发者ID:ccavxx,项目名称:py-search,代码行数:1,代码来源:lilspikey_tests.py
示例10: test_failed_at_set_after_MAX_ATTEMPTS
def test_failed_at_set_after_MAX_ATTEMPTS(self): @tasks.background(name='test_failed_at_set_after_MAX_ATTEMPTS') def failed_at_set_after_MAX_ATTEMPTS(): raise RuntimeError('failed')
开发者ID:ccavxx,项目名称:py-search,代码行数:1,代码来源:lilspikey_tests.py
示例11: test_default_name
def test_default_name(self): proxy = tasks.background()(empty_task) self.assertEqual(proxy.name, 'background_task.tests.empty_task')
开发者ID:ccavxx,项目名称:py-search,代码行数:1,代码来源:lilspikey_tests.py
示例12: empty_task
import unittestfrom django.test import TransactionTestCasefrom django.conf import settings
from datetime import timedelta, datetime
from background_task.tasks import tasks, TaskSchedule, TaskProxyfrom background_task.models import Task, datetime_nowfrom background_task import background
_recorded = []
def empty_task(): pass
def record_task(*arg, **kw): _recorded.append((arg, kw))
class TestBackgroundDecorator(unittest.TestCase):
def test_get_proxy(self): proxy = tasks.background()(empty_task) self.assertNotEqual(proxy, empty_task) self.assertTrue(isinstance(proxy, TaskProxy)) # and alternate form proxy = tasks.background(empty_task) self.assertNotEqual(proxy, empty_task) self.assertTrue(isinstance(proxy, TaskProxy))
def test_default_name(self): proxy = tasks.background()(empty_task) self.assertEqual(proxy.name, 'background_task.tests.empty_task')
proxy = tasks.background()(record_task) self.assertEqual(proxy.name, 'background_task.tests.record_task') proxy = tasks.background(empty_task) #print proxy self.assertTrue(isinstance(proxy, TaskProxy)) self.assertEqual(proxy.name, 'background_task.tests.empty_task')
def test_specified_name(self): proxy = tasks.background(name='mytask')(empty_task) self.assertEqual(proxy.name, 'mytask')
def test_task_function(self): proxy = tasks.background()(empty_task) self.assertEqual(proxy.task_function, empty_task)
proxy = tasks.background()(record_task) self.assertEqual(proxy.task_function, record_task)
def test_default_schedule(self): proxy = tasks.background()(empty_task) self.assertEqual(TaskSchedule(), proxy.schedule)
def test_schedule(self): proxy = tasks.background(schedule=10)(empty_task) self.assertEqual(TaskSchedule(run_at=10), proxy.schedule)
def test__unicode__(self): proxy = tasks.background()(empty_task) self.assertEqual(u'TaskProxy(background_task.tests.empty_task)', unicode(proxy)) def test_shortcut(self): '''check shortcut to decorator works''' proxy = background()(empty_task) self.failIfEqual(proxy, empty_task) self.assertEqual(proxy.task_function, empty_task)
class TestTaskProxy(unittest.TestCase):
def setUp(self): super(TestTaskProxy, self).setUp() self.proxy = tasks.background()(record_task)
def test_run_task(self): tasks.run_task(self.proxy.name, [], {}) self.assertEqual(((), {}), _recorded.pop())
tasks.run_task(self.proxy.name, ['hi'], {}) self.assertEqual((('hi',), {}), _recorded.pop())
tasks.run_task(self.proxy.name, [], {'kw': 1}) self.assertEqual(((), {'kw': 1}), _recorded.pop())
class TestTaskSchedule(unittest.TestCase):
def test_priority(self): self.assertEqual(0, TaskSchedule().priority) self.assertEqual(0, TaskSchedule(priority=0).priority) self.assertEqual(1, TaskSchedule(priority=1).priority) self.assertEqual(2, TaskSchedule(priority=2).priority)
def _within_one_second(self, d1, d2): self.failUnless(isinstance(d1, datetime)) self.failUnless(isinstance(d2, datetime)) self.failUnless(abs(d1 - d2) <= timedelta(seconds=1))
def test_run_at(self): for schedule in [None, 0, timedelta(seconds=0)]: now = datetime_now() run_at = TaskSchedule(run_at=schedule).run_at self._within_one_second(run_at, now)
now = datetime_now() run_at = TaskSchedule(run_at=now).run_at self._within_one_second(run_at, now)
开发者ID:ccavxx,项目名称:py-search,代码行数:31,代码来源:lilspikey_tests.py
示例13: background
def background(*arg, **kw):
from background_task.tasks import tasks
return tasks.background(*arg, **kw)
开发者ID:philippeowagner,项目名称:django-background-tasks,代码行数:3,代码来源:__init__.py
示例14: test_str
def test_str(self):
proxy = tasks.background()(empty_task)
self.assertEqual(
u'TaskProxy(background_task.tests.test_tasks.empty_task)',
str(proxy)
)
开发者ID:arteria,项目名称:django-background-tasks,代码行数:6,代码来源:test_tasks.py
注:本文中的background_task.tasks.tasks.background函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论