From f1aa087127cb9ea0e1706e2a128e17c7c89bf1d4 Mon Sep 17 00:00:00 2001 From: Evilham Date: Thu, 6 Feb 2020 14:40:47 +0100 Subject: [PATCH] Adapt tests to improve BSD support (#633) * Adapt tests to improve BSD support. There was a false Linux|Windows dichotomy in some tests, so instead of skipping certain tests on certain platforms, this now skips tests when *not* on the expected platform. E.g. InotifyFullEmitter tests shouldn't run on non-Linux and the Windows-specific tests shouldn't run on non-Windows. * Revert change to `test_separate_consecutive_moves`. That way CI is happy and changes are conceptually more isolated. --- changelog.rst | 3 ++- tests/test_emitter.py | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/changelog.rst b/changelog.rst index 1cba95b75..fd3edd237 100644 --- a/changelog.rst +++ b/changelog.rst @@ -11,7 +11,8 @@ Changelog - Fixed the ``build_ext`` command on macOS Catalina (`#628 `__) - Refactored ``dispatch()`` method of ``FileSystemEventHandler``, ``PatternMatchingEventHandler`` and ``RegexMatchingEventHandler`` -- Thanks to our beloved contributors: @BoboTiG +- Improve tests support on non Windows/Linux platforms (`#633 `__) +- Thanks to our beloved contributors: @BoboTiG, @evilham 0.10.1 diff --git a/tests/test_emitter.py b/tests/test_emitter.py index 9f96daecc..90b1bf082 100644 --- a/tests/test_emitter.py +++ b/tests/test_emitter.py @@ -48,6 +48,10 @@ from watchdog.observers.read_directory_changes import ( WindowsApiEmitter as Emitter ) +elif platform.is_bsd(): + from watchdog.observers.kqueue import ( + KqueueEmitter as Emitter + ) logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) @@ -177,7 +181,7 @@ def test_move_to(): assert isinstance(event, DirModifiedEvent) -@pytest.mark.skipif(platform.is_windows(), reason="InotifyFullEmitter not supported by Windows") +@pytest.mark.skipif(not platform.is_linux(), reason="InotifyFullEmitter only supported in Linux") def test_move_to_full(): mkdir(p('dir1')) mkdir(p('dir2')) @@ -209,7 +213,7 @@ def test_move_from(): assert isinstance(event, DirModifiedEvent) -@pytest.mark.skipif(platform.is_windows(), reason="InotifyFullEmitter not supported by Windows") +@pytest.mark.skipif(not platform.is_linux(), reason="InotifyFullEmitter only supported in Linux") def test_move_from_full(): mkdir(p('dir1')) mkdir(p('dir2')) @@ -398,8 +402,8 @@ def test_renaming_top_level_directory(): @pytest.mark.flaky(max_runs=5, min_passes=1, rerun_filter=rerun_filter) -@pytest.mark.skipif(platform.is_linux(), - reason="Linux create another set of events for this test") +@pytest.mark.skipif(not platform.is_windows(), + reason="Non-Windows create another set of events for this test") def test_renaming_top_level_directory_on_windows(): start_watching() @@ -485,8 +489,8 @@ def test_move_nested_subdirectories(): @pytest.mark.flaky(max_runs=5, min_passes=1, rerun_filter=rerun_filter) -@pytest.mark.skipif(platform.is_linux(), - reason="Linux create another set of events for this test") +@pytest.mark.skipif(not platform.is_windows(), + reason="Non-Windows create another set of events for this test") def test_move_nested_subdirectories_on_windows(): mkdir(p('dir1/dir2/dir3'), parents=True) touch(p('dir1/dir2/dir3', 'a'))