Skip to content

Commit

Permalink
tests: fix test_schedule_failure_should_not_prevent_future_schedules()
Browse files Browse the repository at this point in the history
  • Loading branch information
BoboTiG committed May 13, 2022
1 parent 3a6eace commit 3e064cf
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tests/test_observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,18 @@ def mocked_start():
assert len(observer.emitters) == 1


def test_schedule_failure_should_not_prevent_future_schedules(monkeypatch, observer):
def test_schedule_failure_should_not_prevent_future_schedules(observer):
observer.start()

# Make the emitter fail on start(), and subsequently the observer to fail on schedule()
def mocked_start(emitter):
def bad_start(_):
raise OSError()
monkeypatch.setattr(EventEmitter, "start", mocked_start)

with pytest.raises(OSError):
with patch.object(EventEmitter, "start", new=bad_start), pytest.raises(OSError):
observer.schedule(None, '')
# The emitter should not be in the list
emitters = observer.emitters
assert len(emitters) == 0
assert not observer.emitters

# Re-schduling the watch should work
# Re-scheduling the watch should work
observer.schedule(None, '')
assert len(observer.emitters) == 1

0 comments on commit 3e064cf

Please sign in to comment.