def test_start(self, inotify): x = InotifyMonitor(['a']) inotify.IN_MODIFY = 1 inotify.IN_ATTRIB = 2 x.start() inotify.WatchManager.side_effect = ValueError() with self.assertRaises(ValueError): x.start() x.stop() x._on_change = None x.process_(Mock()) x._on_change = Mock() x.process_(Mock()) self.assertTrue(x._on_change.called)
def test_start(self, inotify): x = InotifyMonitor(['a']) inotify.IN_MODIFY = 1 inotify.IN_ATTRIB = 2 x.start() inotify.WatchManager.side_effect = ValueError() with self.assertRaises(ValueError): x.start() x.stop() x._on_change = None x.process_(Mock()) x._on_change = Mock() x.process_(Mock()) self.assertTrue(x._on_change.called) x.create_notifier = Mock() x._wm = Mock() hub = Mock() x.register_with_event_loop(hub) x.create_notifier.assert_called_with() hub.add_reader.assert_called_with(x._wm.get_fd(), x.on_readable) x.on_event_loop_close(hub) x._notifier = Mock() x.on_readable() x._notifier.read_events.assert_called_with() x._notifier.process_events.assert_called_with()