diff --git a/tests/modes/test_debug.py b/tests/modes/test_debug.py index a6e68c69a..6c6537d2e 100644 --- a/tests/modes/test_debug.py +++ b/tests/modes/test_debug.py @@ -57,7 +57,7 @@ def test_debug_start(): "mu.modes.debugger.Debugger", mock_debugger_class ), mock.patch.object(venv, "interpreter", "interpreter"): dm.start() - editor.save_tab_to_file.called_once_with(view.current_tab) + editor.save_tab_to_file.assert_called_once_with(view.current_tab) view.add_python3_runner.assert_called_once_with( "interpreter", "/foo/bar", diff --git a/tests/modes/test_pygamezero.py b/tests/modes/test_pygamezero.py index c4a24d782..27ebae251 100644 --- a/tests/modes/test_pygamezero.py +++ b/tests/modes/test_pygamezero.py @@ -126,7 +126,7 @@ def test_pgzero_run_game(): with mock.patch.object(venv, "interpreter", "interpreter"): pm.run_game() - editor.save_tab_to_file.called_once_with(view.current_tab) + editor.save_tab_to_file.assert_called_once_with(view.current_tab) view.add_python3_runner.assert_called_once_with( interpreter="interpreter", script_name="/foo/bar", diff --git a/tests/test_logic.py b/tests/test_logic.py index 0f0316f85..a57c2a0c1 100644 --- a/tests/test_logic.py +++ b/tests/test_logic.py @@ -893,7 +893,7 @@ def test_editor_restore_session_existing_runtime(): assert ed.minify is False assert ed.microbit_runtime == "/foo" assert ed._view.zoom_position == 5 - assert venv_relocate.called_with("foo") + venv_relocate.assert_called_with("foo") def test_editor_restore_session_missing_runtime(): @@ -1069,7 +1069,7 @@ def test_editor_open_focus_passed_file(): with generate_session(): ed.restore_session(paths=[filepath]) - assert ed.direct_load.called_with(filepath) + ed.direct_load.assert_called_with(os.path.abspath(filepath)) def test_editor_session_and_open_focus_passed_file(): @@ -1439,12 +1439,12 @@ def test_load_stores_newline(): newline = "r\n" text = newline.join("the cat sat on the mat".split()) editor = mocked_editor() - with generate_python_file("abc\r\ndef") as filepath: + with generate_python_file(text) as filepath: editor._view.get_load_path.return_value = filepath editor.load() - assert editor._view.add_tab.called_with( - filepath, text, editor.modes[editor.mode].api(), "\r\n" + editor._view.add_tab.assert_called_with( + filepath, text, editor.modes[editor.mode].api(), "\n" ) @@ -1459,7 +1459,7 @@ def test_save_restores_newline(): with mock.patch("mu.logic.save_and_encode") as mock_save: ed = mocked_editor(text=test_text, newline=newline, path=filepath) ed.save() - assert mock_save.called_with(test_text, filepath, newline) + mock_save.assert_called_with(test_text, filepath, newline) def test_save_strips_trailing_spaces(): @@ -2524,7 +2524,7 @@ def test_change_mode_workspace_dir_exception(): ed.change_mode("circuitpython") assert mock_error.call_count == 1 assert ed.mode == "circuitpython" - assert python_mode.workspace_dir.called_once() + python_mode.workspace_dir.assert_called_once_with() def test_autosave(): diff --git a/tests/test_settings.py b/tests/test_settings.py index 87ef50985..a5595b4bc 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -246,8 +246,8 @@ def test_save_only_changed(mocked_open): settings.as_string = mock.Mock(return_value=rstring()) settings.save() - assert settings.as_string.called_with(changed_only=True) - assert mocked_open.called_with(settings.filepath, "w") + settings.as_string.assert_called_with(changed_only=True) + mocked_open.assert_called_with(settings.filepath, "w", encoding="utf-8") @patch.object(mu.settings, "logger")