Slightly cover bootstrap, to increase more and more coverage. Ensure that there is no associated shell

This commit is contained in:
Yohann D'ANELLO 2020-11-10 21:32:10 +01:00
parent e9ac448854
commit 7173d13495
2 changed files with 14 additions and 11 deletions

View File

@ -27,10 +27,9 @@ class MenuDisplay(Display):
self.pad.addstr(self.menu.position, 0, ">")
def display(self) -> None:
if self.height - 2 >= self.menu.position - 1:
cornery = 0
elif self.height - 2 >= self.trueheight - self.menu.position:
cornery = self.trueheight - self.height + 2
cornery = 0 if self.height - 2 >= self.menu.position - 1 \
else self.trueheight - self.height + 2 \
if self.height - 2 >= self.trueheight - self.menu.position else 0
# Menu box
self.menubox.addstr(0, 0, "" + "" * (self.width - 2) + "")

View File

@ -1,8 +1,9 @@
import os
import unittest
from dungeonbattle.bootstrap import Bootstrap
from dungeonbattle.display.display import Display
from dungeonbattle.display.display_manager import DisplayManager
from dungeonbattle.display.statsdisplay import StatsDisplay
from dungeonbattle.game import Game, KeyValues, GameMode
from dungeonbattle.menus import MainMenuValues
@ -21,6 +22,15 @@ class TestGame(unittest.TestCase):
self.assertRaises(NotImplementedError, Game.load_game, "game.save")
self.assertRaises(NotImplementedError, Display(None).display)
def test_bootstrap_fail(self) -> None:
"""
Ensure that the test can't play the game,
because there is no associated shell.
Yeah, that's only for coverage.
"""
self.assertRaises(Exception, Bootstrap.run_game)
self.assertEqual(os.getenv("TERM", "unknown"), "unknown")
def test_key_translation(self) -> None:
"""
Test key bindings.
@ -106,9 +116,3 @@ class TestGame(unittest.TestCase):
self.game.handle_key_pressed(KeyValues.SPACE)
self.assertEqual(self.game.state, GameMode.MAINMENU)
def test_stats_display(self) -> None:
self.game.current_display = StatsDisplay(None)
self.game.current_display.update_player(self.game.player)
self.game.current_display.resize(0, 0, 42, 42)
self.game.current_display.refresh()