Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow musl libc's -1 error message during testing #923

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.rst
Expand Up @@ -11,6 +11,8 @@ Changelog
- [documentation] HTML documentation builds are now tested for errors.
- [fsevents2] The fsevents2 observer is now deprecated.
- [watchmedo] Handle shutdown events from ``SIGHUP`` (`#912 <https://github.com/gorakhargosh/watchdog/pull/912>`__)
- [tests] The error message returned by musl libc for error code ``-1`` is now allowed.
(`#920 <https://github.com/gorakhargosh/watchdog/issues/920>`_)
- Thanks to our beloved contributors: @kurtmckee @babymastodon

2.1.9
Expand Down
16 changes: 9 additions & 7 deletions tests/test_inotify_c.py
Expand Up @@ -135,18 +135,20 @@ def inotify_rm_watch(fd, wd):
assert inotify_fd.wds == [2, 3] # Only 1 is removed explicitly


@pytest.mark.parametrize("error, pattern", [
(errno.ENOSPC, "inotify watch limit reached"),
(errno.EMFILE, "inotify instance limit reached"),
(errno.ENOENT, "No such file or directory"),
(-1, "Unknown error -1"),
@pytest.mark.parametrize("error, patterns", [
(errno.ENOSPC, ("inotify watch limit reached",)),
(errno.EMFILE, ("inotify instance limit reached",)),
(errno.ENOENT, ("No such file or directory",)),
# Error messages for -1 are undocumented
# and vary between libc implementations.
(-1, ("Unknown error -1", "No error information")),
])
def test_raise_error(error, pattern):
def test_raise_error(error, patterns):
with patch.object(ctypes, "get_errno", new=lambda: error):
with pytest.raises(OSError) as exc:
Inotify._raise_error()
assert exc.value.errno == error
assert pattern in str(exc.value)
assert any(pattern in str(exc.value) for pattern in patterns)


def test_non_ascii_path():
Expand Down