import os import unittest from pathlib import Path from sliceitoff.text import Fonts, TextPage from sliceitoff.screens import ( gameover_screen, hiscores_screen, initials_screen, instructions1_screen, instructions2_screen, level_screen, levelup_screen, mainmenu_screen) class TestScreens(unittest.TestCase): def setUp(self): Fonts.load_fonts(os.path.join( Path(__file__).parent.parent.resolve(), "src", "sliceitoff")) def test_can_run_gameover(self): page = gameover_screen() self.assertEqual(TextPage, type(page)) def test_can_run_hiscores(self): page = hiscores_screen("just text") self.assertEqual(TextPage, type(page)) def test_can_run_initials(self): page = initials_screen("VIL") self.assertEqual(TextPage, type(page)) def test_can_run_instructions1(self): page = instructions1_screen() self.assertEqual(TextPage, type(page)) def test_can_run_instructions2(self): page = instructions2_screen() self.assertEqual(TextPage, type(page)) def test_can_run_level(self): page = level_screen(2) self.assertEqual(TextPage, type(page)) def test_can_run_levelup(self): class mock_stats: def __init__(self): self.level = 1 self.enemies = 2 self.field_count = 3 self.lives = 4 self.bonus = 5 self.percent = 5 def calc_bonus(self): return (1,2,3,4,5,6) page = levelup_screen(stats=mock_stats()) self.assertEqual(TextPage, type(page)) def test_can_run_mainmenu(self): page = mainmenu_screen(2) self.assertEqual(TextPage, type(page))