test: reconstruction de la base DuckDB de test avant chaque session (#71)

This commit is contained in:
Colin Maudry
2026-04-16 11:04:44 +02:00
parent cfd0da34cd
commit 94ff13a66b
+13 -5
View File
@@ -1,5 +1,6 @@
import datetime import datetime
import os import os
from pathlib import Path
import polars as pl import polars as pl
import pytest import pytest
@@ -41,12 +42,19 @@ def test_data():
"titulaire_categorie": "PME", "titulaire_categorie": "PME",
} }
] ]
path = "tests/test.parquet" parquet_path = Path(os.path.abspath("tests/test.parquet"))
path = os.path.abspath(path) db_path = parquet_path.parent / "decp.duckdb"
print(f"Writing test data to: {path}") # <-- This will show you the real path print(f"Writing test data to: {parquet_path}")
pl.DataFrame(data).write_parquet("tests/test.parquet") pl.DataFrame(data).write_parquet(parquet_path)
yield 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(): def pytest_setup_options():