expand has/lacks_capability markers to support AND

This commit is contained in:
Lorow
2025-12-07 17:46:31 +01:00
parent 4dba0d5d70
commit d31c1ee502
2 changed files with 14 additions and 15 deletions

View File

@@ -37,10 +37,10 @@ def pytest_addoption(parser):
def pytest_configure(config):
config.addinivalue_line(
"markers", "has_capability(cap): skip if the board does not have the capability"
"markers", "has_capability(caps): skip if the board does not have the capability"
)
config.addinivalue_line(
"markers", "lacks_capability(cap): skip if the board DOES have the capability"
"markers", "lacks_capability(caps): skip if the board DOES have the capability"
)
@@ -60,9 +60,9 @@ def check_capability_marker(request, board_lacks_capability):
"has_capability marker must be provided with a capability to check"
)
required_capability = marker.args[0]
if board_lacks_capability(required_capability):
pytest.skip(f"Board does not have capability {required_capability}")
for capability in marker.args:
if board_lacks_capability(capability):
pytest.skip(f"Board does not have capability {capability}")
@pytest.fixture(autouse=True)
@@ -72,12 +72,12 @@ def check_lacks_capability_marker(request, board_lacks_capability):
raise ValueError(
"lacks_capability marker must be provided with a capability to check"
)
required_capability = lacks_capability_marker.args[0]
if not board_lacks_capability(required_capability):
pytest.skip(
"The board supports given capability: {required_capability}, skipping"
)
for capability in lacks_capability_marker.args:
if not board_lacks_capability(capability):
pytest.skip(
"The board supports given capability: {required_capability}, skipping"
)
@pytest.fixture(scope="session", autouse=True)

View File

@@ -22,8 +22,7 @@ def test_ping_wired(get_openiris_device):
assert not has_command_failed(command_result)
@pytest.mark.has_capability("wired")
@pytest.mark.has_capability("wireless")
@pytest.mark.has_capability("wired", "wireless")
def test_changing_mode_to_wired(get_openiris_device, ensure_board_in_mode, config):
device = get_openiris_device()
@@ -93,8 +92,8 @@ def test_setting_mdns_name_invalid_payload(get_openiris_device, payload):
assert has_command_failed(command_result)
@pytest.mark.has_capability("wired")
@pytest.mark.has_capability("wireless")
@pytest.mark.has_capability("wired", "wireless")
# make this to be has_capabilities instead
def test_reboot_command(get_openiris_device, ensure_board_in_mode, config):
device = ensure_board_in_mode("wifi", get_openiris_device())