From ccb11680fa0820b83fbd267123705ee8aa8cd5ae Mon Sep 17 00:00:00 2001 From: Tove Rumar Date: Fri, 9 Aug 2024 11:44:04 +0200 Subject: [PATCH 1/2] Add a flowcontrol requirement. No device has this feature yet so no need to add it to any device type. FOr the future it would be nice to have type/property groups that a device can have etc --- tests/QA/test_radio.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/QA/test_radio.py b/tests/QA/test_radio.py index 809b41e..88ceaca 100644 --- a/tests/QA/test_radio.py +++ b/tests/QA/test_radio.py @@ -36,17 +36,18 @@ def test_latency_big_packets(self, dev: conftest.BCDevice): requirement = conftest.get_requirement('radio.latencybig') assert(latency(dev.link_uri, requirement['packet_size']) < requirement['limit_high_ms']) - @pytest.mark.skip(reason='This test does not pass reliably. We need flow control between nrf and stm32') + @pytest.mark.requirements("syslink_flowctrl") def test_bandwidth_small_packets(self, dev: conftest.BCDevice): requirement = conftest.get_requirement('radio.bwsmall') assert(bandwidth(dev.link_uri, requirement['packet_size']) > requirement['limit_low']) - @pytest.mark.skip(reason='This test does not pass reliably. We need flow control between nrf and stm32') + @pytest.mark.requirements("syslink_flowctrl") def test_bandwidth_big_packets(self, dev: conftest.BCDevice): requirement = conftest.get_requirement('radio.bwbig') assert(bandwidth(dev.link_uri, requirement['packet_size']) > requirement['limit_low']) - @pytest.mark.skip(reason='This test does not pass reliably. We need flow control between nrf and stm32') + + @pytest.mark.requirements("syslink_flowctrl") def test_reliability(self, dev: conftest.BCDevice): requirement = conftest.get_requirement('radio.reliability') # The bandwidth function will assert if there is any packet loss From 0d3f64eb1284b86263a095b1e898bd85a331ed6b Mon Sep 17 00:00:00 2001 From: Tove Rumar Date: Thu, 8 Aug 2024 14:53:25 +0200 Subject: [PATCH 2/2] Cleanup test generation function to skip if no fixtures for function. It the test does not have any fixtures it does not need any parametrization. The same goes for if the only fixture is the request firxture which is a default fixture added by the pytest framework --- conftest.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/conftest.py b/conftest.py index ed168f0..4c3d996 100644 --- a/conftest.py +++ b/conftest.py @@ -37,13 +37,14 @@ def pytest_generate_tests(metafunc): has_properties = has_properties.args if has_properties else [] exclude_decks = exclude_decks.args if exclude_decks else [] devices = get_devices(has_decks,has_properties, exclude_decks) - if devices: - param_name = 'test_setup' if 'test_setup' in metafunc.fixturenames else 'dev' - metafunc.parametrize(param_name, devices, indirect=True if param_name == 'test_setup' else False, ids=lambda d: d.name) - else: - print(f'No devices found for test {metafunc.definition.name}') - metafunc.parametrize("test_setup", [pytest.param(None, marks=pytest.mark.ignore(reason="No device for test"))]) #This is a bit overly complicated but pytest.skip will skip all tests in module - + for fixture in metafunc.fixturenames: + if fixture == 'request': + continue + if devices: + metafunc.parametrize(fixture, devices, indirect=(fixture=='test_setup') , ids=lambda d: d.name) + else: + print(f'No devices found for test {metafunc.definition.name}') + metafunc.parametrize(fixture, [pytest.param(None, marks=pytest.mark.ignore(reason="No device for test"))]) #This is a bit overly complicated but pytest.skip will skip all tests in modul def pytest_collection_modifyitems(config, items):