Example #1
0
    def test_start(self, stat):

        class st(object):
            st_mtime = time()
        stat.return_value = st()
        x = StatMonitor(['a', 'b'])

        def on_is_set():
            if x.shutdown_event.is_set.call_count > 3:
                return True
            return False
        x.shutdown_event = Mock()
        x.shutdown_event.is_set.side_effect = on_is_set

        x.start()
        x.shutdown_event = Mock()
        stat.side_effect = OSError()
        x.start()
Example #2
0
 def test_mtime_stat_raises(self, stat):
     stat.side_effect = ValueError()
     x = StatMonitor(['a', 'b'])
     x._mtime('a')
Example #3
0
 def test_register_with_event_loop(self):
     hub = Mock(name='hub')
     x = StatMonitor(['a'])
     x.register_with_event_loop(hub)
     hub.call_repeatedly.assert_called_with(2.0, x.find_changes)