Test message display
This commit is contained in:
		| @@ -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: | ||||||
|   | |||||||
| @@ -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) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user