1234567891011121314151617181920212223242526272829303132333435363738394041 |
- """Common configuration shared by all tests in this directory."""
- import re
- from pathlib import Path
- import shutil
- import pytest
- from probs_runner import probs_endpoint
- ROOT = Path(__file__).parent.parent
- @pytest.fixture(scope="class")
- def tmp_path_class(request, tmp_path_factory):
- """Like build-in tmp_path fixture but scoped to class."""
- name = request.node.name
- name = re.sub(r"[\W]", "_", name)
- MAXVAL = 30
- name = name[:MAXVAL]
- return tmp_path_factory.mktemp(name, numbered=True)
- @pytest.fixture(scope="class")
- def rdfox(request, tmp_path_class):
- """Return a function to run a set of datasources"""
- working_dir = tmp_path_class
- data_paths = [
- ROOT / Path(p)
- for p in request.cls.endpoint_data
- ]
- print("Starting endpoint with", data_paths)
- with probs_endpoint(
- data_paths, working_dir, port=12119
- ) as rdfox:
- yield rdfox
- shutil.rmtree(working_dir)
- print("Finished endpoint with", data_paths)
|