Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix asserts for called once in Python 3.12 #2448

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/modes/test_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/modes/test_pygamezero.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions tests/test_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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"
)


Expand All @@ -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():
Expand Down Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading