Beispiel #1
0
 def _start_watching_path(self):
     """Schedule handlers for self.path now that it exists."""
     for watch, handlers in self._stopped_handlers.items():
         for handler in handlers:
             self.schedule(event_handler=handler,
                           path=watch.path,
                           recursive=watch.is_recursive)
     # generate any events for files/dirs in self.path that were
     # created before the watch started (since dispatching is stopped,
     # duplicate events will be caught and ignored)
     with self._lock:
         for emitter in self.emitters:
             dirs = [emitter.watch.path]
             for root in dirs:
                 names = os.listdir(root)
                 paths = [os.path.join(root, name) for name in names]
                 paths.sort(key=os.path.getmtime)
                 for path in paths:
                     if os.path.isdir(path):
                         if emitter.watch.is_recursive:
                             dirs.append(path)
                         event = DirCreatedEvent(path)
                     else:
                         event = FileCreatedEvent(path)
                     emitter.queue_event(event)
     # start dispatching events
     self._start_dispatching()
Beispiel #2
0
    def queue_events(self, timeout):

        if self.stopped_event.wait(timeout):
            return

        with self._lock:
            if not self.should_keep_running():
                return

            # Get event diff between fresh snapshot and previous snapshot.
            # Update snapshot.
            new_snapshot = self._take_snapshot()
            events = DirectorySnapshotDiff(self._snapshot, new_snapshot)
            self._snapshot = new_snapshot

            # Files.
            for src_path in events.files_deleted:
                self.queue_event(FileDeletedEvent(src_path))
            for src_path in events.files_modified:
                self.queue_event(FileModifiedEvent(src_path))
            for src_path in events.files_created:
                self.queue_event(FileCreatedEvent(src_path))
            for src_path, dest_path in events.files_moved:
                self.queue_event(FileMovedEvent(src_path, dest_path))

            # Directories.
            for src_path in events.dirs_deleted:
                self.queue_event(DirDeletedEvent(src_path))
            for src_path in events.dirs_modified:
                self.queue_event(DirModifiedEvent(src_path))
            for src_path in events.dirs_created:
                self.queue_event(DirCreatedEvent(src_path))
            for src_path, dest_path in events.dirs_moved:
                self.queue_event(DirMovedEvent(src_path, dest_path))
Beispiel #3
0
    def test_watchdog(self):

        PublicatorRegistery.unregister('pdf')
        PublicatorRegistery.unregister('epub')
        PublicatorRegistery.unregister('html')

        with open('path', 'w') as f:
            f.write('my_content;/path/to/markdown.md')

        @PublicatorRegistery.register('test', '', '')
        class TestPublicator(Publicator):
            def __init__(self, *__):
                pass

        PublicatorRegistery.get('test').publish = Mock()
        event = FileCreatedEvent('path')
        handler = TutorialIsPublished()
        handler.prepare_generation = Mock()
        handler.finish_generation = Mock()
        handler.on_created(event)

        self.assertTrue(PublicatorRegistery.get('test').publish.called)
        handler.finish_generation.assert_called_with('/path/to', 'path')
        handler.prepare_generation.assert_called_with('/path/to')
        os.remove('path')
Beispiel #4
0
    def test_watchdog(self):

        PublicatorRegistery.unregister("pdf")
        PublicatorRegistery.unregister("epub")
        PublicatorRegistery.unregister("html")

        with open("path", "w") as f:
            f.write("my_content;/path/to/markdown.md")

        @PublicatorRegistery.register("test", "", "")
        class TestPublicator(Publicator):
            def __init__(self, *__):
                pass

        PublicatorRegistery.get("test").publish = Mock()
        event = FileCreatedEvent("path")
        handler = TutorialIsPublished()
        handler.prepare_generation = Mock()
        handler.finish_generation = Mock()
        handler.on_created(event)

        self.assertTrue(PublicatorRegistery.get("test").publish.called)
        handler.finish_generation.assert_called_with("/path/to", "path")
        handler.prepare_generation.assert_called_with("/path/to")
        os.remove("path")
Beispiel #5
0
    def queue_events(self, timeout):
        with self._lock:
            # We don't want to hit the disk continuously.
            # timeout behaves like an interval for polling emitters.
            time.sleep(timeout)

            # Get event diff between fresh snapshot and previous snapshot.
            # Update snapshot.
            new_snapshot = DirectorySnapshot(self.watch.path,
                                             self.watch.is_recursive)
            events = DirectorySnapshotDiff(self._snapshot, new_snapshot)
            self._snapshot = new_snapshot

            # Files.
            for src_path in events.files_deleted:
                self.queue_event(FileDeletedEvent(src_path))
            for src_path in events.files_modified:
                self.queue_event(FileModifiedEvent(src_path))
            for src_path in events.files_created:
                self.queue_event(FileCreatedEvent(src_path))
            for src_path, dest_path in events.files_moved:
                self.queue_event(FileMovedEvent(src_path, dest_path))

            # Directories.
            for src_path in events.dirs_deleted:
                self.queue_event(DirDeletedEvent(src_path))
            for src_path in events.dirs_modified:
                self.queue_event(DirModifiedEvent(src_path))
            for src_path in events.dirs_created:
                self.queue_event(DirCreatedEvent(src_path))
            for src_path, dest_path in events.dirs_moved:
                self.queue_event(DirMovedEvent(src_path, dest_path))
Beispiel #6
0
def test_file_lifecyle():
    start_watching()

    mkfile(p('a'))
    touch(p('a'))
    mv(p('a'), p('b'))
    rm(p('b'))

    expect_event(FileCreatedEvent(p('a')))

    if not platform.is_windows():
        expect_event(DirModifiedEvent(p()))

    if platform.is_linux():
        expect_event(FileClosedEvent(p('a')))
        expect_event(DirModifiedEvent(p()))

    expect_event(FileModifiedEvent(p('a')))

    if platform.is_linux():
        expect_event(FileClosedEvent(p('a')))
        expect_event(DirModifiedEvent(p()))

    expect_event(FileMovedEvent(p('a'), p('b')))

    if not platform.is_windows():
        expect_event(DirModifiedEvent(p()))
        expect_event(DirModifiedEvent(p()))

    expect_event(FileDeletedEvent(p('b')))

    if not platform.is_windows():
        expect_event(DirModifiedEvent(p()))
Beispiel #7
0
    def _start_watching_path(self):
        """Schedule handlers for self.path now that it exists."""
        # re-schedule the saved watches/handlers immediately so we miss as few events
        # as possible
        for watch, handlers in self._stopped_handlers.items():
            for handler in handlers:
                self.schedule(event_handler=handler,
                              path=watch.path,
                              recursive=watch.is_recursive)

        # generate any events for files/dirs in self.path that were created before the
        # watch started (these events might come out of order relative to)
        with self._lock:
            for emitter in self.emitters:
                dirs = [emitter.watch.path]
                for root in dirs:
                    names = os.listdir(root)
                    paths = [os.path.join(root, name) for name in names]
                    paths.sort(key=os.path.getmtime)
                    for path in paths:
                        if os.path.isdir(path):
                            if emitter.watch.is_recursive:
                                dirs.append(path)
                            event = DirCreatedEvent(path)
                        else:
                            event = FileCreatedEvent(path)
                        emitter.queue_event(event)
Beispiel #8
0
def test_recursive_off():
    mkdir(p('dir1'))
    start_watching(recursive=False)
    touch(p('dir1', 'a'))

    with pytest.raises(Empty):
        event_queue.get(timeout=5)

    mkfile(p('b'))
    expect_event(FileCreatedEvent(p('b')))
    if not platform.is_windows():
        expect_event(DirModifiedEvent(p()))

        if platform.is_linux():
            expect_event(FileClosedEvent(p('b')))

    # currently limiting these additional events to macOS only, see https://github.com/gorakhargosh/watchdog/pull/779
    if platform.is_darwin():
        mkdir(p('dir1', 'dir2'))
        with pytest.raises(Empty):
            event_queue.get(timeout=5)
        mkfile(p('dir1', 'dir2', 'somefile'))
        with pytest.raises(Empty):
            event_queue.get(timeout=5)

        mkdir(p('dir3'))
        expect_event(DirModifiedEvent(p()))  # the contents of the parent directory changed

        mv(p('dir1', 'dir2', 'somefile'), p('somefile'))
        expect_event(FileMovedEvent(p('dir1', 'dir2', 'somefile'), p('somefile')))
        expect_event(DirModifiedEvent(p()))

        mv(p('dir1', 'dir2'), p('dir2'))
        expect_event(DirMovedEvent(p('dir1', 'dir2'), p('dir2')))
        expect_event(DirModifiedEvent(p()))
Beispiel #9
0
    def queue_events(self, timeout):
        with self._lock:
            if not self.watch.is_recursive \
                    and self.watch.path not in self.pathnames:
                return
            new_snapshot = DirectorySnapshot(self.watch.path,
                                             self.watch.is_recursive)
            events = new_snapshot - self.snapshot
            self.snapshot = new_snapshot

            # Files.
            for src_path in events.files_deleted:
                self.queue_event(FileDeletedEvent(src_path))
            for src_path in events.files_modified:
                self.queue_event(FileModifiedEvent(src_path))
            for src_path in events.files_created:
                self.queue_event(FileCreatedEvent(src_path))
            for src_path, dest_path in events.files_moved:
                self.queue_event(FileMovedEvent(src_path, dest_path))

            # Directories.
            for src_path in events.dirs_deleted:
                self.queue_event(DirDeletedEvent(src_path))
            for src_path in events.dirs_modified:
                self.queue_event(DirModifiedEvent(src_path))
            for src_path in events.dirs_created:
                self.queue_event(DirCreatedEvent(src_path))
            for src_path, dest_path in events.dirs_moved:
                self.queue_event(DirMovedEvent(src_path, dest_path))
Beispiel #10
0
  def test_dispatch(self):
    # Utilities.
    dir_del_event = DirDeletedEvent('/path/blah.py')
    file_del_event = FileDeletedEvent('/path/blah.txt')
    dir_cre_event = DirCreatedEvent('/path/blah.py')
    file_cre_event = FileCreatedEvent('/path/blah.txt')
    dir_mod_event = DirModifiedEvent('/path/blah.py')
    file_mod_event = FileModifiedEvent('/path/blah.txt')
    dir_mov_event = DirMovedEvent('/path/blah.py', '/path/blah')
    file_mov_event = FileMovedEvent('/path/blah.txt', '/path/blah')

    all_events = [
      dir_mod_event,
      dir_del_event,
      dir_cre_event,
      dir_mov_event,
      file_mod_event,
      file_del_event,
      file_cre_event,
      file_mov_event,
      ]

    handler = _TestableEventHandler()
    for event in all_events:
      handler.dispatch(event)
def test_msoffice_created(sync):

    file_events = [
        FileCreatedEvent(ipath(1)),
        FileDeletedEvent(ipath(1)),
        FileCreatedEvent(ipath(1)),
        FileCreatedEvent("/~$" + ipath(1)),
    ]

    res = [
        FileCreatedEvent(ipath(1)),  # created file
        FileCreatedEvent("/~$" + ipath(1)),  # backup
    ]

    cleaned_events = sync._clean_local_events(file_events)
    assert set(cleaned_events) == set(res)
Beispiel #12
0
    def _watch_dir(self, path):
        contents = _get_contents(path)
        if contents is None:
            return

        self._watchlist.add(path)
        for exists in self._loop(path):
            current_contents = _get_contents(path)
            if current_contents is None:
                break

            added_contents = current_contents - contents
            for filename in added_contents:
                filepath = os.path.join(path, filename)
                self._add(filepath)

                if os.path.isdir(filepath):
                    self.queue_event(DirCreatedEvent(filepath))
                else:
                    self.queue_event(FileCreatedEvent(filepath))

            contents = current_contents
            if os.path.exists(path):
                self.queue_event(DirModifiedEvent(path))

        for filename in contents:
            filepath = os.path.join(path, filename)
            self._watchlist.discard(filepath)
        self._watchlist.discard(path)
        self.queue_event(DirDeletedEvent(path))
    def test_on_created_CallsProcessorWithCorrectArgs(self):
        mock_created_event = FileCreatedEvent("DUMMY_PATH")
        mock_processor = mock.MagicMock()
        mock_processor.handle = mock.MagicMock()

        file_handler = handler.MyHandler(mock_processor)
        file_handler.on_created(mock_created_event)
        mock_processor.handle.assert_called_once_with("DUMMY_PATH")
Beispiel #14
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     # the TestEventHandler instance is set to ignore_directories,
     # as such we won't get a DirModifiedEvent(p()) here.
     self.expected_events = [
         FileCreatedEvent(p('foo.json')),
         FileModifiedEvent(p('foo.json'))
     ]
     self.observed_events = set()
Beispiel #15
0
    def test_command_default_file_event_substitution(self):
        from watchdog.events import FileCreatedEvent

        handler = AutoRunTrick()
        path = '/source/path'
        event = FileCreatedEvent(path)
        command = handler._substitute_command(event)
        expected = "file '/source/path' is created"
        self.assertEqual(expected, command)
def test_gedit_save(sync):

    file_events = [
        FileCreatedEvent(
            "/.gedit-save-UR4EC0"),  # save new version to tmp file
        FileModifiedEvent("/.gedit-save-UR4EC0"),  # modify tmp file
        FileMovedEvent(ipath(1),
                       ipath(1) + "~"),  # move old version to backup
        FileMovedEvent("/.gedit-save-UR4EC0",
                       ipath(1)),  # replace old version with tmp
    ]

    res = [
        FileModifiedEvent(ipath(1)),  # modified file
        FileCreatedEvent(ipath(1) + "~"),  # backup
    ]

    cleaned_events = sync._clean_local_events(file_events)
    assert set(cleaned_events) == set(res)
Beispiel #17
0
    def _gen_renamed_events(self,
                            src_path,
                            is_directory,
                            ref_snapshot,
                            new_snapshot):
        """
        Compares information from two directory snapshots (one taken before
        the rename operation and another taken right after) to determine the
        destination path of the file system object renamed, and yields
        the appropriate events to be queued.
        """
        try:
            f_inode = ref_snapshot.inode(src_path)
        except KeyError:
            # Probably caught a temporary file/directory that was renamed
            # and deleted. Fires a sequence of created and deleted events
            # for the path.
            if is_directory:
                yield DirCreatedEvent(src_path)
                yield DirDeletedEvent(src_path)
            else:
                yield FileCreatedEvent(src_path)
                yield FileDeletedEvent(src_path)
                # We don't process any further and bail out assuming
            # the event represents deletion/creation instead of movement.
            return

        dest_path = new_snapshot.path(f_inode)
        if dest_path is not None:
            dest_path = absolute_path(dest_path)
            if is_directory:
                event = DirMovedEvent(src_path, dest_path)
                yield event
            else:
                yield FileMovedEvent(src_path, dest_path)
            yield self._parent_dir_modified(src_path)
            yield self._parent_dir_modified(dest_path)
            if is_directory:
                # TODO: Do we need to fire moved events for the items
                # inside the directory tree? Does kqueue does this
                # all by itself? Check this and then enable this code
                # only if it doesn't already.
                # A: It doesn't. So I've enabled this block.
                if self.watch.is_recursive:
                    for sub_event in generate_sub_moved_events(src_path, dest_path):
                        yield sub_event
        else:
            # If the new snapshot does not have an inode for the
            # old path, we haven't found the new name. Therefore,
            # we mark it as deleted and remove unregister the path.
            if is_directory:
                yield DirDeletedEvent(src_path)
            else:
                yield FileDeletedEvent(src_path)
            yield self._parent_dir_modified(src_path)
Beispiel #18
0
    def __update_crontab_monitor(
        self,
        configuration,
        src_path,
        state,
    ):

        pid = multiprocessing.current_process().pid

        if state == 'created':

            # logger.debug('(%s) Updating crontab monitor for src_path: %s, event: %s'
            #              % (pid, src_path, state))

            print '(%s) Updating crontab monitor for src_path: %s, event: %s' \
                % (pid, src_path, state)

            if os.path.exists(src_path):

                # _crontab_monitor_lock.acquire()

                if not shared_state['crontab_inotify']._wd_for_path.has_key(src_path):

                    # logger.debug('(%s) Adding watch for: %s' % (pid,
                    #             src_path))

                    shared_state['crontab_inotify'].add_watch(
                        force_utf8(src_path))

                    # Fire 'modified' events for all dirs and files in subpath
                    # to ensure that all crontab files are loaded

                    for ent in scandir(src_path):
                        if ent.is_dir(follow_symlinks=True):

                            # logger.debug('(%s) Dispatch DirCreatedEvent for: %s'
                            #         % (pid, ent.path))

                            shared_state['crontab_handler'].dispatch(
                                DirCreatedEvent(ent.path))
                        elif ent.path.find(configuration.user_settings) \
                                > -1:

                            # logger.debug('(%s) Dispatch FileCreatedEvent for: %s'
                            #         % (pid, ent.path))

                            shared_state['crontab_handler'].dispatch(
                                FileCreatedEvent(ent.path))

                # else:
                #    logger.debug('(%s) crontab_monitor watch already exists for: %s'
                #                  % (pid, src_path))
        else:
            logger.debug('(%s) unhandled event: %s for: %s' % (pid,
                                                               state, src_path))
Beispiel #19
0
def test_single_file_events(sync):

    # only a single event for every path -> no consolidation

    file_events = [
        FileModifiedEvent(ipath(1)),
        FileCreatedEvent(ipath(2)),
        FileDeletedEvent(ipath(3)),
        FileMovedEvent(ipath(4), ipath(5)),
    ]

    res = [
        FileModifiedEvent(ipath(1)),
        FileCreatedEvent(ipath(2)),
        FileDeletedEvent(ipath(3)),
        FileMovedEvent(ipath(4), ipath(5)),
    ]

    cleaned_events = sync._clean_local_events(file_events)
    assert set(cleaned_events) == set(res)
Beispiel #20
0
    def test_start_with_command_not_default_and_event(self):
        """Command not default should execute."""
        from watchdog.events import FileCreatedEvent

        path = '/source/path'
        event = FileCreatedEvent(path)
        handler = AutoRunTrick('echo hello')
        with patch('subprocess.Popen', new=self.PipePopen):
            handler.start(event=event)
        outs, _ = handler._process.communicate()
        self.assertEqual(b'hello\n', outs)
Beispiel #21
0
    def _queue_dirs_modified(self, dirs_modified, ref_snapshot, new_snapshot):
        if dirs_modified:
            for dir_modified in dirs_modified:
                self.queue_event(DirModifiedEvent(dir_modified))

            diff_events = new_snapshot - ref_snapshot
            for file_created in diff_events.files_created:
                self.queue_event(FileCreatedEvent(file_created))

            for directory_created in diff_events.dirs_created:
                self.queue_event(DirCreatedEvent(directory_created))
Beispiel #22
0
    def queue_events(self, timeout):
        # We don't want to hit the disk continuously.
        # timeout behaves like an interval for polling emitters.
        if self.stopped_event.wait(timeout):
            return

        with self._lock:
            if not self.should_keep_running():
                return

            # Get event diff between fresh snapshot and previous snapshot.
            # Update snapshot.
            try:
                new_snapshot = self._take_snapshot()
            except OSError as e:
                if e.errno in DEFAULT_RESUMABLE_ERRNO:
                    return
                elif e.errno == errno.ENOENT:  # The monitor directory has been removed.
                    if not SUPPORT_ENOENT_RECOVERY:
                        self.queue_event(DirDeletedEvent(self.watch.path))
                        self.stop()
                    return
                else:
                    raise
            if self._snapshot.mount != new_snapshot.mount:
                # The mount state of monitor directory has changed, such as a local directory is
                # mounted or a NAS directory is unmounted.
                if not SUPPORT_UNMOUNT_RECOVERY:
                    self.queue_event(DirDeletedEvent(self.watch.path))
                    self.stop()
                return

            events = DirectorySnapshotDiff(self._snapshot, new_snapshot)
            self._snapshot = new_snapshot

            # Files.
            for src_path in events.files_deleted:
                self.queue_event(FileDeletedEvent(src_path))
            for src_path in events.files_modified:
                self.queue_event(FileModifiedEvent(src_path))
            for src_path in events.files_created:
                self.queue_event(FileCreatedEvent(src_path))
            for src_path, dest_path in events.files_moved:
                self.queue_event(FileMovedEvent(src_path, dest_path))

            # Directories.
            for src_path in events.dirs_deleted:
                self.queue_event(DirDeletedEvent(src_path))
            for src_path in events.dirs_modified:
                self.queue_event(DirModifiedEvent(src_path))
            for src_path in events.dirs_created:
                self.queue_event(DirCreatedEvent(src_path))
            for src_path, dest_path in events.dirs_moved:
                self.queue_event(DirMovedEvent(src_path, dest_path))
Beispiel #23
0
    def test_command_default_executed_on_each_event(self):
        """Default logging command should execute once on each event."""
        from watchdog.events import FileCreatedEvent, DirModifiedEvent

        handler = AutoRunTrick()
        file_e = FileCreatedEvent('/source/path/file')
        dir_e = DirModifiedEvent('/source/path')
        handler.dispatch(file_e)
        handler.dispatch(dir_e)
        expected = ("file '/source/path/file' is created\n"
                    "directory '/source/path/' is modified\n")
        self.assertEqual(expected, self.mock_out.getvalue())
Beispiel #24
0
def test_watcher_event_handler():
    def callback():
        pass

    handler = WatcherEventHandler(callback, ['*.txt'])
    handler.dispatch(FileModifiedEvent('file.txt'))
    assert not handler.files

    handler.dispatch(FileCreatedEvent('file.rst'))
    assert 'file.rst' not in handler.files

    handler.dispatch(FileCreatedEvent('file.txt'))
    assert 'file.txt' in handler.files

    old_dt = handler.files['file.txt']
    handler.dispatch(FileModifiedEvent('file.txt'))
    assert old_dt < handler.files['file.txt']

    old_dt += timedelta(seconds=4)
    handler.dispatch(GarbageCollectorEvent(old_dt))
    assert not handler.files
Beispiel #25
0
def test_move_to():
    mkdir(p('dir1'))
    mkdir(p('dir2'))
    mkfile(p('dir1', 'a'))
    start_watching(p('dir2'))

    mv(p('dir1', 'a'), p('dir2', 'b'))

    expect_event(FileCreatedEvent(p('dir2', 'b')))

    if not platform.is_windows():
        expect_event(DirModifiedEvent(p('dir2')))
Beispiel #26
0
def test_create():
    start_watching()
    open(p('a'), 'a').close()

    expect_event(FileCreatedEvent(p('a')))

    if not platform.is_windows():
        expect_event(DirModifiedEvent(p()))

    if platform.is_linux():
        event = event_queue.get(timeout=5)[0]
        assert event.src_path == p('a')
        assert isinstance(event, FileClosedEvent)
Beispiel #27
0
def test_type_changes(sync):

    file_events = [
        # keep as is
        FileDeletedEvent(ipath(1)),
        DirCreatedEvent(ipath(1)),
        # keep as is
        DirDeletedEvent(ipath(2)),
        FileCreatedEvent(ipath(2)),
    ]

    res = [
        # keep as is
        FileDeletedEvent(ipath(1)),
        DirCreatedEvent(ipath(1)),
        # keep as is
        DirDeletedEvent(ipath(2)),
        FileCreatedEvent(ipath(2)),
    ]

    cleaned_events = sync._clean_local_events(file_events)
    assert set(cleaned_events) == set(res)
    def test_create_file(self):
        self.start()

        self.fs(lambda: touch(p('file')))

        expected = [
            FileCreatedEvent(p('file')),
            DirModifiedEvent(p()),
        ]

        got = self.collect_results()

        self.assertEqual(expected, got)
Beispiel #29
0
def test_file_observer():
    class EventHandler(FileSystemEventHandler):
        def on_any_event(self, event):
            print("%s %r %r" % (type(event), getattr(
                event, "src_path", None), getattr(event, "dest_path", None)))

    file_observer = Observer()
    watch = file_observer.schedule(EventHandler(), str(Path("tests/data")))
    emitter = file_observer._emitter_for_watch.get(watch)
    file_observer.setDaemon(True)
    file_observer.start()

    emitter.queue_event(FileCreatedEvent("test.file"))
Beispiel #30
0
 def checkNew(self):
     list_of_files = glob.glob(
         os.path.abspath(self.DIRECTORY_TO_WATCH) +
         '/*fit*')  # * means all if need specific format then *.csv
     list_of_files.sort()
     #print(list_of_files)
     if (len(list_of_files) >= 1):
         latest_file = list_of_files[len(list_of_files) - 1]
         if (self.last_file != latest_file):
             self.last_file = latest_file
             #print("New file - %s." % self.last_file)
             event = FileCreatedEvent(self.last_file)
             self.event_handler.on_any_event(event)
 def test___repr__(self):
   event = FileCreatedEvent(path_1)
   self.assertEqual("<FileCreatedEvent: src_path=%s>" %\
                    path_1, event.__repr__())