Test message display

This commit is contained in:
Yohann D'ANELLO 2020-11-27 18:12:27 +01:00
parent 25ba94b9ac
commit 5faebfe556
2 changed files with 13 additions and 0 deletions

View File

@ -74,6 +74,7 @@ class Game:
""" """
if self.message: if self.message:
self.message = None self.message = None
self.display_actions(DisplayActions.REFRESH)
return return
if self.state == GameMode.PLAY: if self.state == GameMode.PLAY:

View File

@ -4,6 +4,8 @@
import os import os
import unittest import unittest
from squirrelbattle.enums import DisplayActions
from squirrelbattle.bootstrap import Bootstrap from squirrelbattle.bootstrap import Bootstrap
from squirrelbattle.display.display import Display from squirrelbattle.display.display import Display
from squirrelbattle.display.display_manager import DisplayManager from squirrelbattle.display.display_manager import DisplayManager
@ -292,3 +294,13 @@ class TestGame(unittest.TestCase):
Check that some functions are not implemented, only for coverage. Check that some functions are not implemented, only for coverage.
""" """
self.assertRaises(NotImplementedError, Display.display, None) self.assertRaises(NotImplementedError, Display.display, None)
def test_messages(self) -> None:
"""
Display error messages.
"""
self.game.message = "I am an error"
self.game.display_actions(DisplayActions.UPDATE)
self.game.display_actions(DisplayActions.REFRESH)
self.game.handle_key_pressed(None, "random key")
self.assertIsNone(self.game.message)