def setUp(self): self.repl = create_repl() self.repl.matches_iter = MagicIterMock() def add_matches(*args, **kwargs): self.repl.matches_iter.matches = ['aaa', 'aab', 'aac'] self.repl.complete = Mock(side_effect=add_matches, return_value=True)
def test_simple_tab_complete(self): self.repl.matches_iter = MagicIterMock() self.repl.matches_iter.__bool__.return_value = False self.repl.complete = mock.Mock() self.repl.print_line = mock.Mock() self.repl.matches_iter.is_cseq.return_value = False self.repl.show_list = mock.Mock() self.repl.funcprops = mock.Mock() self.repl.arg_pos = mock.Mock() self.repl.matches_iter.cur_line.return_value = (None, "foobar") self.repl.s = "foo" self.repl.tab() self.assertTrue(self.repl.complete.called) self.repl.complete.assert_called_with(tab=True) self.assertEqual(self.repl.s, "foobar")
def test_simple_tab_complete(self): self.repl.matches_iter = MagicIterMock() if py3: self.repl.matches_iter.__bool__.return_value = False else: self.repl.matches_iter.__nonzero__.return_value = False self.repl.complete = Mock() self.repl.print_line = Mock() self.repl.matches_iter.is_cseq.return_value = False self.repl.show_list = Mock() self.repl.argspec = Mock() self.repl.matches_iter.cur_line.return_value = (None, "foobar") self.repl.s = "foo" self.repl.tab() self.assertTrue(self.repl.complete.called) self.repl.complete.assert_called_with(tab=True) self.assertEqual(self.repl.s, "foobar")