Skip to content

Commit

Permalink
Improve test level mechanism, apply to very slow svmbir tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bwohlberg committed Dec 15, 2023
1 parent bbf4e96 commit 9e4f1b1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
19 changes: 18 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,25 @@ def pytest_addoption(parser, pluginmanager):
Level definitions:
1 Critical tests only
2 Skip tests that do have a significant impact on coverage
3 All tests
3 All standard tests
4 Run all tests, including those marked as slow to run
"""
parser.addoption(
"--level", action="store", default=3, type=int, help="Set test level to be run"
)


def pytest_configure(config):
"""Add marker description."""
config.addinivalue_line("markers", "slow: mark test as slow to run")


def pytest_collection_modifyitems(config, items):
"""Skip slow tests depending on selected testing level."""
if config.getoption("--level") >= 4:
# don't skip tests at level 4 or higher
return
level_skip = pytest.mark.skip(reason="test not appropriate for selected level")
for item in items:
if "slow" in item.keywords:
item.add_marker(level_skip)
3 changes: 2 additions & 1 deletion scico/test/linop/xray/test_svmbir.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def make_A(
delta_channel=None,
delta_pixel=None,
):

angles = make_angles(num_angles)
A = XRayTransform(
im.shape,
Expand Down Expand Up @@ -154,6 +153,7 @@ def test_adjoint(
adjoint_test(A)


@pytest.mark.slow
@pytest.mark.skipif(device.platform != "cpu", reason="test hangs on gpu")
def test_prox(
is_3d,
Expand Down Expand Up @@ -185,6 +185,7 @@ def test_prox(
prox_test(v, f, f.prox, alpha=0.25, rtol=5e-4)


@pytest.mark.slow
@pytest.mark.skipif(device.platform != "cpu", reason="test hangs on gpu")
def test_prox_weights(
is_3d,
Expand Down

0 comments on commit 9e4f1b1

Please sign in to comment.