diff --git a/provisioning/ansible/roles/external_mail_handler/files/test_external_mail_handler.py b/provisioning/ansible/roles/external_mail_handler/files/test_external_mail_handler.py index 4225d5f..91c80ad 100644 --- a/provisioning/ansible/roles/external_mail_handler/files/test_external_mail_handler.py +++ b/provisioning/ansible/roles/external_mail_handler/files/test_external_mail_handler.py @@ -83,7 +83,7 @@ async def test_handler(self, handler: CustomHandler): envelope.peer = "127.0.0.1" envelope.mail_to = mail.sender envelope.rcpt_to = [mail.receiver] - envelope.data = mail.to_mime_text().as_string().encode('utf-8') + envelope.data = mail.to_mime_text().as_string().encode("utf-8") await handler.handle_DATA(None, None, envelope) assert handler.swap_sender_receiver.called assert handler.send_mail.called @@ -102,8 +102,9 @@ def test_run(self, responder: Responder): responder.controller.start = Mock() responder.controller.stop = Mock() - with patch("builtins.input", return_value=""): - responder.run() + with patch("time.sleep", side_effect=[None, KeyboardInterrupt]): + with pytest.raises(KeyboardInterrupt): + responder.run() assert responder.init_controller.called assert responder.controller.start.called assert responder.controller.stop.called