Skip to content

Commit f909d84

Browse files
committed
TST: skip test_monitor if it can't import inotify (e.g., on mac)
1 parent 15940b7 commit f909d84

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

tests/test_monitor.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,23 @@
66
from tinydb import TinyDB, Query
77
from subprocess import CalledProcessError
88

9-
from heudiconv.cli.monitor import monitor, process, run_heudiconv, MASK_NEWDIR
9+
try:
10+
from heudiconv.cli.monitor import (monitor, process, run_heudiconv,
11+
MASK_NEWDIR)
12+
13+
Header = namedtuple('header', ['wd', 'mask', 'cookie', 'len'])
14+
header = Header(5, MASK_NEWDIR, 5, 5)
15+
watch_path = b'WATCHME'
16+
filename = b'FILE'
17+
type_names = b'TYPE'
18+
19+
path2 = watch_path + b'/' + filename + b'/subpath'
20+
21+
my_events = [(header, type_names, watch_path, filename),
22+
(header, type_names, path2, b'')]
23+
except AttributeError:
24+
my_events = []
25+
pytestmark = pytest.mark.skip(reason='TODO')
1026

1127

1228
class MockInotifyTree(object):
@@ -26,16 +42,6 @@ def __call__(self):
2642
return self.time
2743

2844

29-
Header = namedtuple('header', ['wd', 'mask', 'cookie', 'len'])
30-
header = Header(5, MASK_NEWDIR, 5, 5)
31-
watch_path = b'WATCHME'
32-
filename = b'FILE'
33-
type_names = b'TYPE'
34-
35-
path2 = watch_path + b'/' + filename + b'/subpath'
36-
37-
my_events = [(header, type_names, watch_path, filename),
38-
(header, type_names, path2, b'')]
3945

4046
@pytest.mark.skip(reason="TODO")
4147
@patch('inotify.adapters.InotifyTree', MockInotifyTree(my_events))

0 commit comments

Comments
 (0)