def test_unschedule_self(observer):
 class EventHandler(FileSystemEventHandler, ):
  def on_modified(self, event):
   observer.unschedule(watch)
   unschedule_finished.set()
 unschedule_finished = Event()
 watch = observer.schedule(EventHandler(), u'')
 observer.start()
 (emitter,) = observer.emitters
 emitter.queue_event(FileModifiedEvent(u''))
 assert unschedule_finished.wait()
 assert (len(observer.emitters) == 0)

def test_unschedule_self ( observer ) : class EventHandler ( FileSystemEventHandler , ) : def on_modified ( self , event ) : observer . unschedule ( watch ) unschedule_finished . set ( ) unschedule_finished = Event ( ) watch = observer . schedule ( EventHandler ( ) , u'' ) observer . start ( ) ( emitter , ) = observer . emitters emitter . queue_event ( FileModifiedEvent ( u'' ) ) assert unschedule_finished . wait ( ) assert ( len ( observer . emitters ) == 0 )
tests that unscheduling a watch from within an event handler correctly correctly unregisters emitter and handler without deadlocking .