Skip to content

Commit 8b5c1f2

Browse files
author
Vasu Jaganath
committed
add correct hooks for unittest and install pytest as deps in CI
1 parent c84f947 commit 8b5c1f2

File tree

7 files changed

+39
-10
lines changed

7 files changed

+39
-10
lines changed

.github/workflows/publish_pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}"
8484
CIBW_ARCHS: ${{ matrix.cibw_archs }}
8585
CIBW_BEFORE_TEST_LINUX: dnf -y install maven java
86-
CIBW_TEST_REQUIRES: bfio>=2.4.0 tensorstore numpy
86+
CIBW_TEST_REQUIRES: bfio>=2.4.0 tensorstore numpy pytest
8787
CIBW_TEST_COMMAND: python -W default -m unittest discover -s {project}/tests -v
8888

8989
- name: Install Dependencies
@@ -143,7 +143,7 @@ jobs:
143143
DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-listdeps {wheel} &&
144144
MACOSX_DEPLOYMENT_TARGET=11.0 DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel} -e libc++ -e libunwind
145145
CIBW_ARCHS: ${{ matrix.cibw_archs }}
146-
CIBW_TEST_REQUIRES: bfio>=2.4.0 tensorstore numpy
146+
CIBW_TEST_REQUIRES: bfio>=2.4.0 tensorstore numpy pytest
147147
CIBW_TEST_COMMAND: python -W default -m unittest discover -s {project}/tests -v
148148

149149
- name: Install Dependencies

.github/workflows/wheel_build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}"
8383
CIBW_ARCHS: ${{ matrix.cibw_archs }}
8484
CIBW_BEFORE_TEST_LINUX: dnf -y install maven java
85-
CIBW_TEST_REQUIRES: bfio>=2.4.0 tensorstore numpy
85+
CIBW_TEST_REQUIRES: bfio>=2.4.0 tensorstore numpy pytest
8686
CIBW_TEST_COMMAND: python -W default -m unittest discover -s {project}/tests -v
8787

8888
- name: Upload Artifact
@@ -139,7 +139,7 @@ jobs:
139139
DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-listdeps {wheel} &&
140140
MACOSX_DEPLOYMENT_TARGET=11.0 DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel} -e libc++ -e libunwind
141141
CIBW_ARCHS: ${{ matrix.cibw_archs }}
142-
CIBW_TEST_REQUIRES: bfio>=2.4.0 tensorstore numpy
142+
CIBW_TEST_REQUIRES: bfio>=2.4.0 tensorstore numpy pytest
143143
CIBW_TEST_COMMAND: python -W default -m unittest discover -s {project}/tests -v
144144

145145
- name: Upload Artifact

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ python_files =
55
test_*.py
66
addopts =
77
--ignore=tests/python/test_read.py
8+
--ignore=tests/python/test_pytest_bridge.py
89
markers =
910
integration: integration tests that touch disk/network

tests/python/io_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class PolusTestDataRepo:
99
repo_url: str = "https://github.com/sameeul/polus-test-data.git"
1010
repo_dir: Path = Path("polus-test-data")
11-
default_branch: str = "main" # used only if you later add pull/update logic
11+
default_branch: str = "main"
1212

1313

1414
def ensure_repo_cloned(repo: PolusTestDataRepo, depth: int = 1) -> Path:

tests/python/test_pytest_bridge.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import os
2+
import subprocess
3+
import sys
4+
import unittest
5+
from pathlib import Path
6+
7+
8+
if "PYTEST_CURRENT_TEST" in os.environ:
9+
raise unittest.SkipTest("pytest bridge should not run under pytest")
10+
11+
class TestPytestSuite(unittest.TestCase):
12+
"""Run pytest-based tests under unittest-driven CI."""
13+
def test_pytest(self) -> None:
14+
"The entry point of pytest execution"
15+
tests_python = Path(__file__).resolve().parent # tests/python
16+
17+
env = os.environ.copy()
18+
env["PYTEST_DISABLE_PLUGIN_AUTOLOAD"] = "1"
19+
20+
subprocess.run(
21+
[
22+
sys.executable,
23+
"-m",
24+
"pytest",
25+
"-vv",
26+
"-s",
27+
str(tests_python),
28+
],
29+
check=True,
30+
env=env,
31+
timeout=900,
32+
)

tests/python/test_single_image.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ def test_single_image_pyramid(tmp_path: Path) -> None:
2222
output_dir=out_dir,
2323
)
2424

25-
shapes = assert_is_argolid_omexml_zarr_pyramid(out_dir, expect_levels=2)
2625
shapes = assert_is_argolid_omexml_zarr_pyramid(out_dir, expect_levels=2)
2726

2827
# ensure at least one spatial dimension shrinks between level 0 and 1
2928
y0, x0 = shapes[0][-2], shapes[0][-1]
3029
y1, x1 = shapes[1][-2], shapes[1][-1]
3130
assert (y1 < y0) or (x1 < x0), f"Expected level 1 to be downsampled vs level 0, got L0={shapes[0]} L1={shapes[1]}"
32-

tests/python/zarr_assertions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def find_argolid_root(out_dir: Path) -> Path:
4343
return candidates[0]
4444

4545
if len(candidates) > 1:
46-
# deterministic choice, newest wins
4746
return max(candidates, key=lambda p: p.stat().st_mtime)
4847

4948
raise FileNotFoundError(
@@ -85,7 +84,7 @@ def assert_is_argolid_omexml_zarr_pyramid(out_dir: Path, expect_levels: int | No
8584
series0 = data["0"]
8685
assert isinstance(series0, zarr.Group)
8786

88-
# levels can be arrays or groups, depending on how the writer stored them
87+
# levels can be arrays or groups
8988
level_names = sorted(
9089
[k for k in series0.keys() if str(k).isdigit()],
9190
key=lambda s: int(s),
@@ -122,7 +121,6 @@ def assert_is_argolid_omexml_zarr_pyramid(out_dir: Path, expect_levels: int | No
122121

123122
raise AssertionError(f"Unexpected type at level {lvl}: {type(node)}")
124123

125-
# after shapes computed:
126124
assert shapes, "No shapes collected from pyramid levels"
127125
y0, x0 = shapes[0][-2], shapes[0][-1]
128126
assert y0 > 0 and x0 > 0, "Each array must have non-zero shape"

0 commit comments

Comments
 (0)