mirror of
https://github.com/p2p-ld/numpydantic.git
synced 2025-01-09 21:44:27 +00:00
steps towards parallel-friendly tests, but not quite there yet.
This commit is contained in:
parent
6ce3d58528
commit
22f6023d35
4 changed files with 11 additions and 7 deletions
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
|
@ -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
|
||||||
|
|
12
tests/fixtures/paths.py
vendored
12
tests/fixtures/paths.py
vendored
|
@ -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
|
||||||
|
|
|
@ -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)))
|
||||||
|
|
|
@ -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")
|
||||||
|
|
Loading…
Reference in a new issue