def test_autocomplete_event(self): Equal = self.assertEqual autocomplete = self.autocomplete # Test that the autocomplete event is ignored if user is pressing a # modifier key in addition to the tab key ev = Event(mc_state=True) self.assertIsNone(autocomplete.autocomplete_event(ev)) del ev.mc_state # If autocomplete window is open, complete() method is called self.text.insert('1.0', 're.') # This must call autocomplete._make_autocomplete_window() Equal(self.autocomplete.autocomplete_event(ev), 'break') # If autocomplete window is not active or does not exist, # open_completions is called. Return depends on its return. autocomplete._remove_autocomplete_window() o_cs = Func() # .result = None autocomplete.open_completions = o_cs Equal(self.autocomplete.autocomplete_event(ev), None) Equal(o_cs.args, (False, True, True)) o_cs.result = True Equal(self.autocomplete.autocomplete_event(ev), 'break') Equal(o_cs.args, (False, True, True))
def test_autocomplete_event(self): Equal = self.assertEqual acp = self.autocomplete # Result of autocomplete event: If modified tab, None. ev = Event(mc_state=True) self.assertIsNone(acp.autocomplete_event(ev)) del ev.mc_state # If tab after whitespace, None. self.text.insert('1.0', ' """Docstring.\n ') self.assertIsNone(acp.autocomplete_event(ev)) self.text.delete('1.0', 'end') # If active autocomplete window, complete() and 'break'. self.text.insert('1.0', 're.') acp.autocompletewindow = mock = Mock() mock.is_active = Mock(return_value=True) Equal(acp.autocomplete_event(ev), 'break') mock.complete.assert_called_once() acp.autocompletewindow = None # If no active autocomplete window, open_completions(), None/break. open_c = Func(result=False) acp.open_completions = open_c Equal(acp.autocomplete_event(ev), None) Equal(open_c.args[0], ac.TAB) open_c.result = True Equal(acp.autocomplete_event(ev), 'break') Equal(open_c.args[0], ac.TAB)
def test_autocomplete_event(self): Equal = self.assertEqual autocomplete = self.autocomplete ev = Event(mc_state=True) self.assertIsNone(autocomplete.autocomplete_event(ev)) del ev.mc_state self.text.insert('1.0', ' """Docstring.\n ') self.assertIsNone(autocomplete.autocomplete_event(ev)) self.text.delete('1.0', 'end') self.text.insert('1.0', 're.') Equal(self.autocomplete.autocomplete_event(ev), 'break') autocomplete._remove_autocomplete_window() o_cs = Func() autocomplete.open_completions = o_cs Equal(self.autocomplete.autocomplete_event(ev), None) Equal(o_cs.args, (False, True, True)) o_cs.result = True Equal(self.autocomplete.autocomplete_event(ev), 'break') Equal(o_cs.args, (False, True, True))