Skip to content

Commit

Permalink
[tests] Fix flakey watch deletion test for FSEvents (#891)
Browse files Browse the repository at this point in the history
* maintain log level during test

* update changelog
  • Loading branch information
samschott committed May 20, 2022
1 parent 68ef624 commit 5e5cb4a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Unreleased

2022-xx-xx • `full history <https://github.com/gorakhargosh/watchdog/compare/v2.1.8...HEAD>`__

-
- Thanks to our beloved contributors: @
- [fsevents] Fix flakey test to assert that there are no errors when stopping the emitter.
- Thanks to our beloved contributors: @samschott

2.1.8
~~~~~
Expand Down
19 changes: 10 additions & 9 deletions tests/test_fsevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,20 @@ def stop(em):
th2 = Thread(target=stop, args=(emitter,))

try:
with caplog.at_level(logging.ERROR):
th1.start()
th2.start()
th1.join()
th2.join()
assert not caplog.records
th1.start()
th2.start()
th1.join()
th2.join()
finally:
emitter.stop()

# 20 attempts to make the random failure happen
for _ in range(20):
try_to_fail()
sleep(random())
with caplog.at_level(logging.ERROR):
for _ in range(20):
try_to_fail()
sleep(random())

assert not caplog.records


def test_remove_watch_twice():
Expand Down

0 comments on commit 5e5cb4a

Please sign in to comment.