Skip to content

Commit

Permalink
Enable warn_unreachable for twisted.python.test.test_inotify
Browse files Browse the repository at this point in the history
  • Loading branch information
wsanchez committed Sep 25, 2020
1 parent c3e3f6a commit e85e81e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,6 @@ warn_unreachable = False
[mypy-twisted.persisted.sob]
warn_unreachable = False

[mypy-twisted.python.test.test_inotify]
warn_unreachable = False

[mypy-twisted.web.http_headers]
warn_unreachable = False

Expand Down
18 changes: 12 additions & 6 deletions src/twisted/python/test/test_inotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,26 @@
from twisted.python.filepath import FilePath
from twisted.python.runtime import platform

if platform.supportsINotify():
from ctypes import c_int, c_uint32, c_char_p
try:
from twisted.python import _inotify
except ImportError:
inotify = None
else:
inotify = _inotify

if inotify and platform.supportsINotify():
from ctypes import c_int, c_uint32, c_char_p
from twisted.python._inotify import INotifyError, initializeModule, init, add
else:
_inotify = None # type: ignore[assignment]
inotify = None


class INotifyTests(TestCase):
"""
Tests for L{twisted.python._inotify}.
"""

if _inotify is None:
if inotify is None:
skip = "This platform doesn't support INotify."

def test_missingInit(self):
Expand Down Expand Up @@ -114,7 +120,7 @@ class libc:
def inotify_init(self):
return -1

self.patch(_inotify, "libc", libc())
self.patch(inotify, "libc", libc())
self.assertRaises(INotifyError, init)

def test_failedAddWatch(self):
Expand All @@ -127,5 +133,5 @@ class libc:
def inotify_add_watch(self, fd, path, mask):
return -1

self.patch(_inotify, "libc", libc())
self.patch(inotify, "libc", libc())
self.assertRaises(INotifyError, add, 3, FilePath("/foo"), 0)

0 comments on commit e85e81e

Please sign in to comment.