From 74aaf0776de53708e676d307cecbc6a9bd71abd9 Mon Sep 17 00:00:00 2001 From: DannyAbdi <dannyabdi13@gmail.com> Date: Sat, 16 Mar 2024 02:46:27 +0000 Subject: [PATCH] Created test class for Player class --- testPlayer.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 testPlayer.py diff --git a/testPlayer.py b/testPlayer.py new file mode 100644 index 0000000..a3386cc --- /dev/null +++ b/testPlayer.py @@ -0,0 +1,18 @@ +import unittest +from unittest.mock import Mock, patch +from config import TILE_SIZE +from player import Player + + +class TestPlayer(unittest.TestCase): + @patch('pygame.draw.rect') + def test_draw(self, mock_rect): + # Mock the screen surface + screen_surface_mock = Mock() + player = Player(10, 20) + player.draw(screen_surface_mock) + mock_rect.assert_called_once_with(screen_surface_mock, 'white', (10, 20, TILE_SIZE, TILE_SIZE)) + + +if __name__ == "__main__": + unittest.main() -- GitLab