Skip to content

Commit

Permalink
Test added
Browse files Browse the repository at this point in the history
  • Loading branch information
rrzaripov committed Mar 26, 2019
1 parent 450f534 commit 8d5f60b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/watchdog/observers/inotify_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def _recursive_simulate(src_path):
self._path_for_wd[moved_wd] = inotify_event.src_path
if self.is_recursive:
for _path, _wd in self._wd_for_path.items():
if _path.startswith(move_src_path):
if _path.startswith(move_src_path + os.path.sep.encode()):
moved_wd = self._wd_for_path[_path]
del self._wd_for_path[_path]
_move_to_path = _path.replace(move_src_path, inotify_event.src_path)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,15 @@ def test_recursive_off():

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


def test_renaming_top_level_directory():
mkdir(p('a', 'b'), True)
mv(p('a'), p('a2'))
start_watching()
open(p('a2', 'b', 'c'), 'a').close()

event = event_queue.get(timeout=5)[0]
print(event)
assert event.src_path == p('a2', 'b', 'c')
assert isinstance(event, FileCreatedEvent)

0 comments on commit 8d5f60b

Please sign in to comment.