diff --git a/changelog.rst b/changelog.rst index b9f4c9df..e2b0b034 100644 --- a/changelog.rst +++ b/changelog.rst @@ -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 `__) +- [tests] The error message returned by musl libc for error code ``-1`` is now allowed. + (`#920 `_) - Thanks to our beloved contributors: @kurtmckee @babymastodon 2.1.9 diff --git a/tests/test_inotify_c.py b/tests/test_inotify_c.py index b4f49699..f0c99304 100644 --- a/tests/test_inotify_c.py +++ b/tests/test_inotify_c.py @@ -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():