From 94ff13a66b845b22695bd21060b390796b473fbb Mon Sep 17 00:00:00 2001 From: Colin Maudry Date: Thu, 16 Apr 2026 11:04:44 +0200 Subject: [PATCH] test: reconstruction de la base DuckDB de test avant chaque session (#71) --- tests/conftest.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1874b52..df103aa 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,6 @@ import datetime import os +from pathlib import Path import polars as pl import pytest @@ -41,12 +42,19 @@ def test_data(): "titulaire_categorie": "PME", } ] - path = "tests/test.parquet" - path = os.path.abspath(path) - print(f"Writing test data to: {path}") # <-- This will show you the real path + parquet_path = Path(os.path.abspath("tests/test.parquet")) + db_path = parquet_path.parent / "decp.duckdb" + print(f"Writing test data to: {parquet_path}") - pl.DataFrame(data).write_parquet("tests/test.parquet") - yield path + pl.DataFrame(data).write_parquet(parquet_path) + + # Remove any stale DuckDB from a previous run so src.db rebuilds from + # the freshly-written parquet at import time. + for artifact in (db_path, db_path.with_suffix(".duckdb.tmp")): + if artifact.exists(): + artifact.unlink() + + yield str(parquet_path) def pytest_setup_options():