Cover the language change

This commit is contained in:
Yohann D'ANELLO 2020-11-27 21:56:25 +01:00
parent 31b7ece449
commit f07324662a
2 changed files with 12 additions and 5 deletions

View File

@ -15,6 +15,7 @@ from squirrelbattle.entities.player import Player
from squirrelbattle.game import Game, KeyValues, GameMode
from squirrelbattle.menus import MainMenuValues
from squirrelbattle.settings import Settings
from squirrelbattle.translations import gettext as _
class TestGame(unittest.TestCase):
@ -275,12 +276,18 @@ class TestGame(unittest.TestCase):
self.game.handle_key_pressed(KeyValues.ENTER)
self.assertEqual(self.game.settings.TEXTURE_PACK, "ascii")
# Change language
self.game.settings.LOCALE = "en"
self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.ENTER)
self.assertEqual(self.game.settings.LOCALE, "fr")
self.assertEqual(_("New game"), "Nouvelle partie")
self.game.handle_key_pressed(KeyValues.ENTER)
self.assertEqual(self.game.settings.LOCALE, "en")
self.assertEqual(_("New game"), "New game")
# Navigate to "back" button
self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.ENTER)
self.assertEqual(self.game.state, GameMode.MAINMENU)

View File

@ -7,7 +7,7 @@ class TestTranslations(unittest.TestCase):
def setUp(self) -> None:
setlocale("fr")
def test_translations(self):
def test_translations(self) -> None:
"""
Ensure that some strings are well-translated.
"""