intake/tests/conftest.py

31 lines
706 B
Python
Raw Normal View History

2023-06-04 22:31:08 +00:00
from pathlib import Path
from typing import List, Callable
import pytest
from intake.source import LocalSource
def clean_source(source_path: Path):
for item in source_path.iterdir():
if item.name.endswith(".item"):
item.unlink()
(source_path / "state").unlink(missing_ok=True)
@pytest.fixture
def using_source() -> Callable:
test_data = Path(__file__).parent
sources: List[Path] = []
def _using_source(name: str):
source_path = test_data / name
clean_source(source_path)
sources.append(source_path)
return LocalSource(test_data, name)
2024-09-21 21:55:10 +00:00
2023-06-04 22:31:08 +00:00
yield _using_source
for source_path in sources:
clean_source(source_path)