예제 #1
0
def observer2():
    obs = BaseObserver(EventEmitter)
    yield obs
    obs.stop()
    try:
        obs.join()
    except RuntimeError:
        pass
예제 #2
0
def observer2():
    obs = BaseObserver(EventEmitter)
    yield obs
    obs.stop()
    try:
        obs.join()
    except RuntimeError:
        pass
예제 #3
0
    def test_basic(self):
        observer = BaseObserver(EventEmitter)
        handler = LoggingEventHandler()

        watch = observer.schedule(handler, "/foobar", True)
        observer.add_handler_for_watch(handler, watch)
        observer.add_handler_for_watch(handler, watch)
        observer.remove_handler_for_watch(handler, watch)
        self.assertRaises(KeyError, observer.remove_handler_for_watch, handler, watch)
        observer.unschedule(watch)
        self.assertRaises(KeyError, observer.unschedule, watch)

        watch = observer.schedule(handler, "/foobar", True)
        observer.event_queue.put((FileModifiedEvent("/foobar"), watch))
        observer.start()
        time.sleep(1)
        observer.unschedule_all()
        observer.stop()
  def test_basic(self):
    observer = BaseObserver(EventEmitter)
    handler = LoggingEventHandler()

    watch = observer.schedule(handler, '/foobar', True)
    observer.add_handler_for_watch(handler, watch)
    observer.add_handler_for_watch(handler, watch)
    observer.remove_handler_for_watch(handler, watch)
    self.assertRaises(KeyError,
                      observer.remove_handler_for_watch, handler, watch)
    observer.unschedule(watch)
    self.assertRaises(KeyError, observer.unschedule, watch)

    watch = observer.schedule(handler, '/foobar', True)
    observer.event_queue.put((FileModifiedEvent('/foobar'), watch))
    observer.start()
    time.sleep(1)
    observer.unschedule_all()
    observer.stop()
예제 #5
0
def test_observer_basic():
    observer = BaseObserver(EventEmitter)
    handler = LoggingEventHandler()

    watch = observer.schedule(handler, '/foobar', True)
    observer.add_handler_for_watch(handler, watch)
    observer.add_handler_for_watch(handler, watch)
    observer.remove_handler_for_watch(handler, watch)
    with pytest.raises(KeyError):
        observer.remove_handler_for_watch(handler, watch)
    observer.unschedule(watch)
    with pytest.raises(KeyError):
        observer.unschedule(watch)

    watch = observer.schedule(handler, '/foobar', True)
    observer.event_queue.put((FileModifiedEvent('/foobar'), watch))
    observer.start()
    time.sleep(1)
    observer.unschedule_all()
    observer.stop()
예제 #6
0
def observer2():
    obs = BaseObserver(EventEmitter)
    yield obs
    obs.stop()
    with contextlib.suppress(RuntimeError):
        obs.join()
예제 #7
0
def observer2():
    obs = BaseObserver(EventEmitter)
    yield obs
    obs.stop()