From 828ace9db1d09753a1aabeddb2716553ad528b0c Mon Sep 17 00:00:00 2001 From: Joltras <72395471+Joltras@users.noreply.github.com> Date: Fri, 11 Sep 2026 22:13:54 +0200 Subject: [PATCH 1/4] =?UTF-8?q?test:=20make=20pytest=20runnable=20without?= =?UTF-8?q?=20manual=20PYTHONPATH,=20fix=20stale=20asser=E2=80=A6=20(#101)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Claude-Session: https://claude.ai/code/session_013qzxv6dWjnaUYoVpG8pQ58 Co-authored-by: Claude Sonnet 5 --- 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) From 6d736a8a612c461b986bc7d04c40434cade2d055 Mon Sep 17 00:00:00 2001 From: Joltras <72395471+Joltras@users.noreply.github.com> Date: Fri, 11 Sep 2026 22:24:45 +0200 Subject: [PATCH 2/4] fix: Fix application path (#102) * fix: fix path to project root * fix: fix path to project root * feat: ignore generated json files --- .gitignore | 1 - src/utils/globals.py | 5 ++--- test/globals_test.py | 6 ++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index bda025b..2ab8488 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .idea /generation -src/utils/generation/ __pycache__/ .python-version diff --git a/src/utils/globals.py b/src/utils/globals.py index 33a7388..f14beb9 100644 --- a/src/utils/globals.py +++ b/src/utils/globals.py @@ -52,9 +52,8 @@ class Color(Enum): # Json BASE_INDENT = " " JSON_SUFFIX = ".json" -APPLICATION_PATH = os.path.realpath( - os.path.dirname(__file__).replace("\\src", "").replace("\\utils", "") -) +_CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) +APPLICATION_PATH = os.path.dirname(os.path.dirname(_CURRENT_DIR)) DEFAULT_FLOOR_NAME = "floor" DEFAULT_FLOOR_DIRECTORY = "generation" diff --git a/test/globals_test.py b/test/globals_test.py index a65d56e..383cf6c 100644 --- a/test/globals_test.py +++ b/test/globals_test.py @@ -92,10 +92,8 @@ def test_json_suffix(self): self.assertEqual(".json", globals.JSON_SUFFIX) def test_path(self): - self.assertEqual( - os.path.realpath(os.path.dirname(__file__).replace("\\test", "")), - globals.APPLICATION_PATH, - ) + project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + self.assertEqual(project_root, globals.APPLICATION_PATH) if __name__ == "__main__": From 407fd1f58a87443f27d8cf6cf9ab491cf2249460 Mon Sep 17 00:00:00 2001 From: Joltras Date: Fri, 11 Sep 2026 22:33:40 +0200 Subject: [PATCH 3/4] feat: add github workflow --- .github/workflows/ci.yaml | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..a6b7d3d --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,40 @@ +name: CI + +on: + push: + branches: [ dev ] + pull_request: + branches: [ dev ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.14" + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Run tests + run: pytest + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.14" + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Run pylint + run: pylint src --rcfile=.pylintrc --fail-under=9.5 From 79a6036201279e8d1b30f4f9ada6121c862436ba Mon Sep 17 00:00:00 2001 From: Joltras Date: Fri, 11 Sep 2026 22:36:22 +0200 Subject: [PATCH 4/4] fix: remove suggestion mode --- .pylintrc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.pylintrc b/.pylintrc index 86c9322..8417cf1 100644 --- a/.pylintrc +++ b/.pylintrc @@ -99,10 +99,6 @@ recursive=no # source root. source-roots= -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages. -suggestion-mode=yes - # Allow loading of arbitrary C extensions. Extensions are imported into the # active Python interpreter and may run arbitrary code. unsafe-load-any-extension=no