From 2060ca949dafbe8b55d1868c5a03b4d1e4305fa2 Mon Sep 17 00:00:00 2001 From: Spark Date: Sun, 11 Oct 2026 09:41:15 -0400 Subject: [PATCH] =?UTF-8?q?fix(ci):=20la=20collecte=20des=20tests=20=C3=A9?= =?UTF-8?q?chouait=20sous=20le=20binaire=20pytest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit from tests.conftest import ... levait ModuleNotFoundError en CI : le binaire pytest n'ajoute pas le répertoire courant à sys.path, contrairement à python -m pytest (utilisé en local, qui masquait le problème). Correctifs : tests/__init__.py (package), pythonpath=[.] dans la config pytest, et étape CI en python -m pytest. Vérifié : 36/36 dans les trois modes d'invocation. --- .gitea/workflows/ci.yml | 2 +- pyproject.toml | 4 ++++ tests/__init__.py | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/__init__.py diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0ab9b8e..5a86110 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -17,4 +17,4 @@ jobs: - name: Compile check run: python -m py_compile app/*.py - name: Tests - run: pytest -q + run: python -m pytest -q diff --git a/pyproject.toml b/pyproject.toml index 0139f2c..831eef0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,3 +24,7 @@ dev = [ [tool.pytest.ini_options] testpaths = ["tests"] asyncio_mode = "auto" +# Always put the repo root on sys.path: the plain `pytest` binary (CI) +# does not add the CWD, unlike `python -m pytest` — without this, +# `from tests.conftest import ...` fails at collection time in CI. +pythonpath = ["."] diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..94981e6 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,8 @@ +"""Kanbante test suite. + +This package marker matters: with it, pytest puts the repository root on +sys.path, so `from tests.conftest import ...` resolves identically +whether the suite is launched via the `pytest` binary (CI) or via +`python -m pytest` (which additionally adds the CWD). The root is also +pinned explicitly through `pythonpath` in pyproject.toml. +"""