Skip to content

Commit

Permalink
Adapt tests to improve BSD support (#633)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
evilham committed Feb 6, 2020
1 parent b752e37 commit f1aa087
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Changelog
- Fixed the ``build_ext`` command on macOS Catalina (`#628 <https://github.com/gorakhargosh/watchdog/pull/628>`__)
- Refactored ``dispatch()`` method of ``FileSystemEventHandler``,
``PatternMatchingEventHandler`` and ``RegexMatchingEventHandler``
- Thanks to our beloved contributors: @BoboTiG
- Improve tests support on non Windows/Linux platforms (`#633 <https://github.com/gorakhargosh/watchdog/pull/633>`__)
- Thanks to our beloved contributors: @BoboTiG, @evilham


0.10.1
Expand Down
16 changes: 10 additions & 6 deletions tests/test_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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'))
Expand Down Expand Up @@ -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'))
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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'))
Expand Down

0 comments on commit f1aa087

Please sign in to comment.