From 249164eb9b565eb54d37655737f2b0d9a00e7544 Mon Sep 17 00:00:00 2001 From: Luca Benci Date: Fri, 27 Oct 2017 22:25:41 +0200 Subject: [PATCH] Fix `test_quickcomplete_flicker` The test needed to be fixed because of how the completer behaviour changed. Before: completer always scheduled a completion update on selection changed, but the updates themselves were ignored if not needed. Now: completer only schedules completion updates when actually needed, but never ignores a completion update. So, before it was correct to check whether `set_model` was called, now we must check if the completion was actually scheduled. This can be done by checking the parameters with which `_change_completed_part` is called, since a completion is scheduled only when `immediate=True` --- tests/unit/completion/test_completer.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/unit/completion/test_completer.py b/tests/unit/completion/test_completer.py index 8575cf02d..5f1581aa0 100644 --- a/tests/unit/completion/test_completer.py +++ b/tests/unit/completion/test_completer.py @@ -299,6 +299,12 @@ def test_quickcomplete_flicker(status_command_stub, completer_obj, config_stub.val.completion.quick = True _set_cmd_prompt(status_command_stub, ':open |') - completer_obj.on_selection_changed('http://example.com') - completer_obj.schedule_completion_update() - assert not completion_widget_stub.set_model.called + + url = 'http://example.com' + completer_obj._change_completed_part = unittest.mock.Mock() + completer_obj.on_selection_changed(url) + + # no immediate (default is false) + completer_obj._change_completed_part.assert_called_with(url, # text + ['open'], # before + []) # after