mirror of
https://github.com/meshtastic/python.git
synced 2026-04-20 14:58:54 -04:00
fix errors and better linux/windows handling in tests
This commit is contained in:
@@ -979,10 +979,11 @@ def test_main_set_valid(mocked_findports, mocked_serial, mocked_open, mocked_hup
|
||||
|
||||
@pytest.mark.unit
|
||||
@pytest.mark.usefixtures("reset_mt_config")
|
||||
@patch("meshtastic.serial_interface.SerialInterface._set_hupcl_with_termios")
|
||||
@patch("builtins.open", new_callable=mock_open, read_data="data")
|
||||
@patch("serial.Serial")
|
||||
@patch("meshtastic.util.findPorts", return_value=["/dev/ttyUSBfake"])
|
||||
def test_main_set_valid_wifi_psk(mocked_findports, mocked_serial, mocked_open, capsys):
|
||||
def test_main_set_valid_wifi_psk(mocked_findports, mocked_serial, mocked_open, mocked_hupcl, capsys):
|
||||
"""Test --set with valid field"""
|
||||
sys.argv = ["", "--set", "network.wifi_psk", "123456789"]
|
||||
mt_config.args = sys.argv
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Meshtastic unit tests for serial_interface.py"""
|
||||
import platform
|
||||
# pylint: disable=R0917
|
||||
|
||||
import re
|
||||
import sys
|
||||
from unittest.mock import mock_open, patch
|
||||
|
||||
import pytest
|
||||
@@ -10,7 +10,6 @@ import pytest
|
||||
from ..serial_interface import SerialInterface
|
||||
from ..protobuf import config_pb2
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@patch("time.sleep")
|
||||
@patch("meshtastic.serial_interface.SerialInterface._set_hupcl_with_termios")
|
||||
@@ -28,11 +27,11 @@ def test_SerialInterface_single_port(
|
||||
iface.close()
|
||||
mocked_findPorts.assert_called()
|
||||
mocked_serial.assert_called()
|
||||
mock_hupcl.assert_called()
|
||||
|
||||
# doesn't get called in SerialInterface._set_hupcl_with_termios on windows
|
||||
if platform.system() != "Windows":
|
||||
# doesn't get called in SerialInterface on windows
|
||||
if sys.platform != "win32":
|
||||
mocked_open.assert_called()
|
||||
mock_hupcl.assert_called()
|
||||
|
||||
mock_sleep.assert_called()
|
||||
out, err = capsys.readouterr()
|
||||
|
||||
Reference in New Issue
Block a user