Skip to content

Commit b468fc3

Browse files
committed
Speedup tests via fixture scoping
1 parent 262a910 commit b468fc3

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ ignore_missing_imports = true
6262

6363
[tool.pytest.ini_options]
6464
log_level = "INFO"
65+
filterwarnings = [
66+
"ignore:duckdb-engine doesn't yet support reflection on indices:duckdb_engine.DuckDBEngineWarning",
67+
]
6568

6669
[tool.ruff]
6770
target-version = "py312"

tests/conftest.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def timdex_dataset_config() -> TIMDEXDatasetConfig:
5959
return TIMDEXDatasetConfig()
6060

6161

62-
@pytest.fixture
62+
@pytest.fixture(scope="module")
6363
def timdex_dataset_config_small() -> TIMDEXDatasetConfig:
6464
"""Small file configuration for testing partitioning behavior."""
6565
return TIMDEXDatasetConfig(max_rows_per_group=75, max_rows_per_file=75)
@@ -85,13 +85,14 @@ def timdex_dataset(tmp_path, timdex_dataset_config) -> TIMDEXDataset:
8585
return dataset
8686

8787

88-
@pytest.fixture
89-
def timdex_dataset_multi_source(tmp_path) -> TIMDEXDataset:
88+
@pytest.fixture(scope="module")
89+
def timdex_dataset_multi_source(tmp_path_factory) -> TIMDEXDataset:
9090
"""TIMDEXDataset with multiple sources for testing filtering.
9191
9292
Contains 1000 records each from: alma, dspace, aspace, libguides, gismit
9393
"""
94-
dataset = TIMDEXDataset(str(tmp_path / "multi_source_dataset/"))
94+
dataset_dir = tmp_path_factory.mktemp("multi_source_dataset_mod")
95+
dataset = TIMDEXDataset(str(dataset_dir))
9596

9697
for source, run_id in [
9798
("alma", "abc123"),
@@ -117,8 +118,10 @@ def timdex_dataset_multi_source(tmp_path) -> TIMDEXDataset:
117118
return dataset
118119

119120

120-
@pytest.fixture
121-
def timdex_dataset_with_runs(tmp_path, timdex_dataset_config_small) -> TIMDEXDataset:
121+
@pytest.fixture(scope="module")
122+
def timdex_dataset_with_runs(
123+
tmp_path_factory, timdex_dataset_config_small
124+
) -> TIMDEXDataset:
122125
"""TIMDEXDataset with multiple full and daily ETL runs.
123126
124127
Simulates realistic ETL pattern with:
@@ -128,7 +131,8 @@ def timdex_dataset_with_runs(tmp_path, timdex_dataset_config_small) -> TIMDEXDat
128131
- Small file sizes to test partitioning
129132
"""
130133
dataset = TIMDEXDataset(
131-
str(tmp_path / "dataset_with_runs/"), config=timdex_dataset_config_small
134+
str(tmp_path_factory.mktemp("dataset_with_runs_mod")),
135+
config=timdex_dataset_config_small,
132136
)
133137

134138
# alma ETL runs
@@ -214,7 +218,7 @@ def timdex_dataset_same_day_runs(tmp_path) -> TIMDEXDataset:
214218
# ================================================================================
215219

216220

217-
@pytest.fixture
221+
@pytest.fixture(scope="module")
218222
def timdex_metadata(timdex_dataset_with_runs) -> TIMDEXDatasetMetadata:
219223
"""TIMDEXDatasetMetadata with static database file created."""
220224
metadata = TIMDEXDatasetMetadata(timdex_dataset_with_runs.location)
@@ -223,7 +227,7 @@ def timdex_metadata(timdex_dataset_with_runs) -> TIMDEXDatasetMetadata:
223227
return metadata
224228

225229

226-
@pytest.fixture
230+
@pytest.fixture(scope="module")
227231
def timdex_dataset_with_runs_with_metadata(
228232
timdex_dataset_with_runs,
229233
) -> TIMDEXDataset:

0 commit comments

Comments
 (0)