Skip to content

Commit

Permalink
Fix setup(loop=None)
Browse files Browse the repository at this point in the history
Caught in issue #24.
  • Loading branch information
rbarrois committed May 15, 2024
1 parent b112604 commit 39e8ef4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aionotify/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def setup(self, loop=None):
self._setup_watch(alias, path, flags)

# We pass ownership of the fd to the transport; it will close it.
self._stream, self._transport = await aioutils.stream_from_fd(self._fd, loop)
self._stream, self._transport = await aioutils.stream_from_fd(self._fd, self._loop)

def close(self):
"""Schedule closure.
Expand Down
13 changes: 13 additions & 0 deletions tests/test_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ async def test_watch_before_start(self):
# And it's over.
await self._assert_no_events()

async def test_watch_before_start_default_loop(self):
"""A watch call is valid before startup."""
self.watcher.watch(self.testdir, aionotify.Flags.CREATE)
await self.watcher.setup()

# Touch a file: we get the event.
self._touch('a')
event = await self.watcher.get_event()
self._assert_file_event(event, 'a')

# And it's over.
await self._assert_no_events()

async def test_watch_after_start(self):
"""A watch call is valid after startup."""
await self.watcher.setup(self.loop)
Expand Down

0 comments on commit 39e8ef4

Please sign in to comment.