本文整理汇总了Python中celery.worker.autoreload.Autoreloader类的典型用法代码示例。如果您正苦于以下问题:Python Autoreloader类的具体用法?Python Autoreloader怎么用?Python Autoreloader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Autoreloader类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_stop
def test_stop(self):
x = Autoreloader(Mock(), modules=[__name__])
x._monitor = None
x.stop()
x._monitor = Mock()
x.stop()
x._monitor.stop.assert_called_with()
示例2: test_on_event_loop_close
def test_on_event_loop_close(self):
x = Autoreloader(Mock(), modules=[__name__])
hub = Mock()
x._monitor = Mock()
x.on_event_loop_close(hub)
x._monitor.on_event_loop_close.assert_called_with(hub)
x._monitor = None
x.on_event_loop_close(hub)
示例3: test_start
def test_start(self, fhash):
x = Autoreloader(Mock(), modules=[__name__])
x.Monitor = Mock()
mon = x.Monitor.return_value = Mock()
mon.start.side_effect = OSError()
mon.start.side_effect.errno = errno.EINTR
x.body()
mon.start.side_effect.errno = errno.ENOENT
with self.assertRaises(OSError):
x.body()
mon.start.side_effect = None
x.body()
示例4: test_on_change
def test_on_change(self):
x = Autoreloader(Mock(), modules=[__name__])
mm = x._maybe_modified = Mock(0)
mm.return_value = True
x._reload = Mock()
x.file_to_module[__name__] = __name__
x.on_change([__name__])
self.assertTrue(x._reload.called)
mm.return_value = False
x.on_change([__name__])
示例5: test_maybe_modified
def test_maybe_modified(self, exists, fhash):
exists.return_value = True
fhash.return_value = 'abcd'
x = Autoreloader(Mock(), modules=[__name__])
x._hashes = {}
x._hashes[__name__] = 'dcba'
self.assertTrue(x._maybe_modified(__name__))
x._hashes[__name__] = 'abcd'
self.assertFalse(x._maybe_modified(__name__))
exists.return_value = False
self.assertFalse(x._maybe_modified(__name__))
示例6: test_maybe_modified
def test_maybe_modified(self, fhash):
fhash.return_value = "abcd"
x = Autoreloader(Mock(), modules=[__name__])
x._hashes = {}
x._hashes[__name__] = "dcba"
self.assertTrue(x._maybe_modified(__name__))
x._hashes[__name__] = "abcd"
self.assertFalse(x._maybe_modified(__name__))
示例7: test_on_poll_init
def test_on_poll_init(self):
x = Autoreloader(Mock(), modules=[__name__])
hub = Mock()
x._monitor = None
x.on_init = Mock()
def se(*args, **kwargs):
x._monitor = Mock()
x.on_init.side_effect = se
x.on_poll_init(hub)
x.on_init.assert_called_with()
x._monitor.on_poll_init.assert_called_with(hub)
x._monitor.on_poll_init.reset_mock()
x.on_poll_init(hub)
x._monitor.on_poll_init.assert_called_with(hub)
示例8: test_register_with_event_loop
def test_register_with_event_loop(self):
x = Autoreloader(Mock(), modules=[__name__])
hub = Mock()
x._monitor = None
x.on_init = Mock()
def se(*args, **kwargs):
x._monitor = Mock()
x.on_init.side_effect = se
x.register_with_event_loop(hub)
x.on_init.assert_called_with()
x._monitor.register_with_event_loop.assert_called_with(hub)
x._monitor.register_with_event_loop.reset_mock()
x.register_with_event_loop(hub)
x._monitor.register_with_event_loop.assert_called_with(hub)
示例9: test_reload
def test_reload(self):
x = Autoreloader(Mock(), modules=[__name__])
x._reload([__name__])
x.controller.reload.assert_called_with([__name__], reload=True)
示例10: test_module_name
def test_module_name(self):
x = Autoreloader(Mock(), modules=[__name__])
self.assertEqual(x._module_name("foo/bar/baz.py"), "baz")