From 2690eb8760a570fea44ee3c03f95b4d5010903bb Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 26 Nov 2020 22:32:25 +0100 Subject: [PATCH] Update FakePad to fix tests --- squirrelbattle/display/display.py | 3 ++- squirrelbattle/tests/screen.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/squirrelbattle/display/display.py b/squirrelbattle/display/display.py index 1d70159..bd16344 100644 --- a/squirrelbattle/display/display.py +++ b/squirrelbattle/display/display.py @@ -71,7 +71,8 @@ class Display: """ top_y, top_x = max(0, top_y), max(0, top_x) window_y, window_x = max(0, window_y), max(0, window_x) - screen_max_y, screen_max_x = self.screen.getmaxyx() + screen_max_y, screen_max_x = self.screen.getmaxyx() if self.screen \ + else 42, 42 last_y, last_x = min(screen_max_y - 1, last_y), \ min(screen_max_x - 1, last_x) diff --git a/squirrelbattle/tests/screen.py b/squirrelbattle/tests/screen.py index 6eb2cd0..a6b3c9a 100644 --- a/squirrelbattle/tests/screen.py +++ b/squirrelbattle/tests/screen.py @@ -1,3 +1,6 @@ +from typing import Tuple + + class FakePad: """ In order to run tests, we simulate a fake curses pad that accepts functions @@ -10,8 +13,11 @@ class FakePad: smincol: int, smaxrow: int, smaxcol: int) -> None: pass - def clear(self) -> None: + def erase(self) -> None: pass def resize(self, height: int, width: int) -> None: pass + + def getmaxyx(self) -> Tuple[int, int]: + return 42, 42