setup.cfg | 2 -- tests/shell.py | 5 +++++ tests/test_emitter.py | 8 ++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index 8c5532b..5130285 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,5 +26,3 @@ upload-dir = docs/build/html addopts = --showlocals -v - --cov=watchdog - --cov-report=term-missing diff --git a/tests/shell.py b/tests/shell.py index 0e7305a..bdf8991 100644 --- a/tests/shell.py +++ b/tests/shell.py @@ -26,6 +26,7 @@ import shutil import errno import time +import pytest # def tree(path='.', show_files=False): # print(path) @@ -124,8 +125,12 @@ def msize(path): def mount_tmpfs(path): + if os.environ.get("NO_SUDO") is not None: + pytest.skip("Requires sudo") os.system(f"sudo mount -t tmpfs none {path}") def unmount(path): + if os.environ.get("NO_SUDO") is not None: + return os.system(f"sudo umount {path}") diff --git a/tests/test_emitter.py b/tests/test_emitter.py index 1721b30..1572f91 100644 --- a/tests/test_emitter.py +++ b/tests/test_emitter.py @@ -145,9 +145,13 @@ def test_close(): assert os.path.normpath(event.src_path) == os.path.normpath(p("")) assert isinstance(event, DirModifiedEvent) - # After read-only, only IN_CLOSE_NOWRITE is emitted but not caught for now #747 - open(p("a"), "r").close() + f_d = open(p("a"), "r") + event = event_queue.get(timeout=5)[0] + assert event.src_path == p("a") + assert isinstance(event, FileOpenedEvent) + f_d.close() + # After read-only, only IN_CLOSE_NOWRITE is emitted but not caught for now #747 assert event_queue.empty()