From 8ca692a26ea60adcaf3e6fe571ed0493d6cef78c Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Thu, 6 Jan 2022 12:33:30 -0800 Subject: [PATCH] cannot call os.getlogin() on github instances --- meshtastic/tests/test_main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/meshtastic/tests/test_main.py b/meshtastic/tests/test_main.py index 150a210..a39a6ac 100644 --- a/meshtastic/tests/test_main.py +++ b/meshtastic/tests/test_main.py @@ -202,11 +202,14 @@ def test_main_info(capsys, reset_globals): @pytest.mark.unit -def test_main_info_with_permission_error(capsys, caplog, reset_globals): +@patch('os.getlogin') +def test_main_info_with_permission_error(patched_getlogin, capsys, caplog, reset_globals): """Test --info""" sys.argv = ['', '--info'] Globals.getInstance().set_args(sys.argv) + patched_getlogin.return_value = 'me' + iface = MagicMock(autospec=SerialInterface) with caplog.at_level(logging.DEBUG): with pytest.raises(SystemExit) as pytest_wrapped_e: @@ -216,6 +219,7 @@ def test_main_info_with_permission_error(capsys, caplog, reset_globals): assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 1 out, err = capsys.readouterr() + patched_getlogin.assert_called() assert re.search(r'Need to add yourself', out, re.MULTILINE) assert err == ''