From 424889a639bc1aa9e04009987453bc20ae974be6 Mon Sep 17 00:00:00 2001 From: Joltras Date: Fri, 11 Sep 2026 22:07:41 +0200 Subject: [PATCH] test: make pytest runnable without manual PYTHONPATH, fix stale assertions pytest previously required PYTHONPATH=src (only set in the Dockerfile) to even collect the test modules, and nothing enforced it, so `pytest` failed outright from a plain checkout. Add pyproject.toml pytest config that puts src on the path and add pytest to requirements.txt. Also update three tests that had drifted from the implementation: - test_room_types expected 7 room types, RoomType now has 8 (SECRET_ROOM) - test_room_colors referenced the removed globals.Room_Colors instead of the current utils.room_type.room_colors - test_to_json's expected string predates the "_seed" field in Floor.to_json globals_test.py::test_path is left failing on purpose - it's tracking a real bug in APPLICATION_PATH (Windows-only path stripping) to be fixed in a follow-up branch. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_013qzxv6dWjnaUYoVpG8pQ58 --- pyproject.toml | 3 +++ requirements.txt | 3 ++- test/floor_test.py | 2 +- test/globals_test.py | 11 ++++++----- 4 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e85ba17 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.pytest.ini_options] +pythonpath = ["src"] +testpaths = ["test"] diff --git a/requirements.txt b/requirements.txt index 19dd031..5247ce4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,5 @@ black~=26.5.1 pylint~=4.0.2 flake8~=7.3.0 mypy~=2.3.0 -pillow~=12.3.0 \ No newline at end of file +pillow~=12.3.0 +pytest~=9.1.1 \ No newline at end of file diff --git a/test/floor_test.py b/test/floor_test.py index 8fa85b1..5a273a6 100644 --- a/test/floor_test.py +++ b/test/floor_test.py @@ -18,7 +18,7 @@ def setUp(self) -> None: self._floor_with_rooms.add_room(5, 5) def test_to_json(self): - expected = '{\n "_rooms": []\n}' + expected = '{\n "_seed": "1",\n "_rooms": []\n}' self.assertEqual(expected, self._floor.to_json(1)) def test_contains_room(self): diff --git a/test/globals_test.py b/test/globals_test.py index dded816..a65d56e 100644 --- a/test/globals_test.py +++ b/test/globals_test.py @@ -49,7 +49,7 @@ def test_door_faces(self): self.assertEqual(expected, globals.DoorFace.list()) def test_room_types(self): - expected = [0, 1, 2, 3, 4, 5, 6] + expected = [0, 1, 2, 3, 4, 5, 6, 7] self.assertEqual(expected, RoomType.list()) def test_special_rooms(self): @@ -62,15 +62,16 @@ def test_door_color(self): def test_room_colors(self): expected = { - RoomType.NORMAL_ROOM: Color.VIOLET, - RoomType.DEAD_END: Color.VIOLET, + RoomType.NORMAL_ROOM: Color.LIGHT_GRAY, + RoomType.DEAD_END: Color.LIGHT_GRAY, RoomType.ITEM_ROOM: Color.GREEN, RoomType.SHOP_ROOM: Color.YELLOW, RoomType.START_ROOM: Color.ORANGE, - RoomType.TELEPORT_ROOM: Color.GRAY, + RoomType.TELEPORT_ROOM: Color.VIOLET, RoomType.BOSS_ROOM: Color.RED, + RoomType.SECRET_ROOM: Color.BLUE, } - self.assertEqual(expected, globals.Room_Colors) + self.assertEqual(expected, room_type.room_colors) def test_room_width(self): self.assertEqual(120, globals.ROOM_WIDTH)