steps towards parallel-friendly tests, but not quite there yet.

This commit is contained in:
sneakers-the-rat 2024-10-18 20:11:58 -07:00
parent 6ce3d58528
commit 22f6023d35
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
4 changed files with 11 additions and 7 deletions

View file

@ -47,7 +47,7 @@ jobs:
run: pip install "numpy${{ matrix.numpy-version }}" run: pip install "numpy${{ matrix.numpy-version }}"
- name: Run Tests - name: Run Tests
run: pytest -n auto run: pytest
- name: Coveralls Parallel - name: Coveralls Parallel
uses: coverallsapp/github-action@v2.3.0 uses: coverallsapp/github-action@v2.3.0

View file

@ -10,7 +10,7 @@ def tmp_output_dir(request: pytest.FixtureRequest) -> Path:
path = Path(__file__).parents[1].resolve() / "__tmp__" path = Path(__file__).parents[1].resolve() / "__tmp__"
if path.exists(): if path.exists():
shutil.rmtree(str(path)) shutil.rmtree(str(path))
path.mkdir() path.mkdir(parents=True, exist_ok=True)
yield path yield path
@ -26,15 +26,19 @@ def tmp_output_dir(request: pytest.FixtureRequest) -> Path:
@pytest.fixture(scope="function") @pytest.fixture(scope="function")
def tmp_output_dir_func(tmp_output_dir, request: pytest.FixtureRequest) -> Path: def tmp_output_dir_func(
tmp_output_dir, testrun_uid, request: pytest.FixtureRequest
) -> Path:
""" """
tmp output dir that gets cleared between every function tmp output dir that gets cleared between every function
cleans at the start rather than at cleanup in case the output is to be inspected cleans at the start rather than at cleanup in case the output is to be inspected
""" """
subpath = tmp_output_dir / f"__tmpfunc_{request.node.name}__" subpath = tmp_output_dir / f"__tmpfunc_{request.node.name}__"
if testrun_uid:
subpath = subpath / testrun_uid
if subpath.exists(): if subpath.exists():
shutil.rmtree(str(subpath)) shutil.rmtree(str(subpath))
subpath.mkdir() subpath.mkdir(parents=True)
return subpath return subpath
@ -47,5 +51,5 @@ def tmp_output_dir_mod(tmp_output_dir, request: pytest.FixtureRequest) -> Path:
subpath = tmp_output_dir / f"__tmpmod_{request.module}__" subpath = tmp_output_dir / f"__tmpmod_{request.module}__"
if subpath.exists(): if subpath.exists():
shutil.rmtree(str(subpath)) shutil.rmtree(str(subpath))
subpath.mkdir() subpath.mkdir(parents=True)
return subpath return subpath

View file

@ -389,7 +389,7 @@ def test_callable():
annotation = NDArray[Shape["3"], int] annotation = NDArray[Shape["3"], int]
array = np.array([1, 2, 3], dtype=int) array = np.array([1, 2, 3], dtype=int)
validated = annotation(array) validated = annotation(array)
assert validated is array assert np.array_equal(validated, array)
with pytest.raises(DtypeError): with pytest.raises(DtypeError):
_ = annotation(np.zeros((1, 2, 3))) _ = annotation(np.zeros((1, 2, 3)))

View file

@ -39,7 +39,7 @@ def test_validation_case_merge():
"interface", "interface",
[ [
pytest.param( pytest.param(
i.interface, marks=getattr(pytest.mark, i.interface.interface.name) i.interface, id=i.id, marks=getattr(pytest.mark, i.interface.interface.name)
) )
for i in INTERFACE_CASES for i in INTERFACE_CASES
if i.id not in ("hdf5_compound") if i.id not in ("hdf5_compound")