From ada45ca86021ef065cfc08f4cfb0f9c07ad8c2b1 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Fri, 10 Dec 2021 10:20:16 -0800 Subject: [PATCH] make unit tests pass even if hardware is connected serially --- meshtastic/tests/test_main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meshtastic/tests/test_main.py b/meshtastic/tests/test_main.py index dbfbe23..8bd8742 100644 --- a/meshtastic/tests/test_main.py +++ b/meshtastic/tests/test_main.py @@ -103,7 +103,8 @@ def test_main_support(capsys): @pytest.mark.unit -def test_main_ch_index_no_devices(capsys): +@patch('meshtastic.util.findPorts', return_value=[]) +def test_main_ch_index_no_devices(patched_find_ports, capsys): """Test --ch-index 1""" sys.argv = ['', '--ch-index', '1'] args = sys.argv @@ -122,6 +123,7 @@ def test_main_ch_index_no_devices(capsys): out, err = capsys.readouterr() assert re.search(r'Warning: No Meshtastic devices detected', out, re.MULTILINE) assert err == '' + patched_find_ports.assert_called() @pytest.mark.unit