Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Boenninghausen committed Oct 23, 2024
1 parent 83ed0da commit c25918c
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,19 @@ def test_init_controller(self, responder: Responder):

def test_run(self, responder: Responder):
responder.init_controller = Mock()
responder.controller = Mock() # Mock the controller object itself
responder.controller = Mock()
responder.controller.start = Mock()
responder.controller.stop = Mock()

with patch("time.sleep", side_effect=[None, KeyboardInterrupt]):
with pytest.raises(KeyboardInterrupt):
with patch("time.sleep", side_effect=[KeyboardInterrupt]):
try:
responder.run()
except KeyboardInterrupt:
pass # Allow the KeyboardInterrupt to break the loop

assert responder.init_controller.called
assert responder.controller.start.called
assert responder.controller.stop.called
assert not responder.controller.stop.called


@pytest.fixture()
Expand Down

0 comments on commit c25918c

Please sign in to comment.