Example #1
0
 def matches_from_completions(self, cursor, line, block, history,
                              completions):
     with mock.patch('bpython.autocomplete.jedi.Script') as Script:
         script = Script.return_value
         script.completions.return_value = completions
         com = autocomplete.MultilineJediCompletion()
         return com.matches(cursor, line, current_block=block,
                            history=history)
Example #2
0
 def matches_from_completions(self, cursor, line, block, history,
                              completions):
     with mock.patch('bpython.autocomplete.jedi.Script') as Script:
         script = Script.return_value
         script.completions.return_value = completions
         com = autocomplete.MultilineJediCompletion()
         return com.matches(cursor, line, current_block=block,
                            history=history)
Example #3
0
 def test_list_win_not_visible_and_match_selected_if_one_option(self):
     self.repl._current_line = " './a'"
     self.repl._cursor_offset = 5
     with mock.patch('bpython.autocomplete.get_completer') as m:
         m.return_value = (['./abcd'], autocomplete.FilenameCompletion())
         self.repl.update_completion()
         self.assertEqual(self.repl.list_win_visible, False)
     self.repl.on_tab()
     self.assertEqual(self.repl._current_line, " './abcd'")
     self.assertEqual(self.repl.current_match, None)
     self.assertEqual(self.repl.list_win_visible, False)
Example #4
0
 def test_list_win_visible_match_selected_on_tab_multiple_options(self):
     self.repl._current_line = " './'"
     self.repl._cursor_offset = 2
     with mock.patch('bpython.autocomplete.get_completer') as m:
         m.return_value = (['./abc', './abcd', './bcd'],
                           autocomplete.FilenameCompletion())
         self.repl.update_completion()
         self.assertEqual(self.repl.list_win_visible, False)
         self.repl.on_tab()
     self.assertEqual(self.repl.current_match, './abc')
     self.assertEqual(self.repl.list_win_visible, True)
Example #5
0
 def test_list_win_not_visible_and_match_selected_if_one_option(self):
     self.repl._current_line = " './a'"
     self.repl._cursor_offset = 5
     with mock.patch('bpython.autocomplete.get_completer_bpython') as m:
         m.return_value = (['./abcd'], autocomplete.FilenameCompletion())
         self.repl.update_completion()
         self.assertEqual(self.repl.list_win_visible, False)
     self.repl.on_tab()
     self.assertEqual(self.repl._current_line, " './abcd'")
     self.assertEqual(self.repl.current_match, None)
     self.assertEqual(self.repl.list_win_visible, False)
Example #6
0
 def test_list_win_visible_match_selected_on_tab_multiple_options(self):
     self.repl._current_line = " './'"
     self.repl._cursor_offset = 2
     with mock.patch('bpython.autocomplete.get_completer_bpython') as m:
         m.return_value = (['./abc', './abcd',
                            './bcd'], autocomplete.FilenameCompletion())
         self.repl.update_completion()
         self.assertEqual(self.repl.list_win_visible, False)
         self.repl.on_tab()
     self.assertEqual(self.repl.current_match, './abc')
     self.assertEqual(self.repl.list_win_visible, True)
Example #7
0
 def test_list_win_not_visible_and_cseq_if_cseq(self):
     self.repl._current_line = " './a'"
     self.repl._cursor_offset = 5
     with mock.patch("bpython.autocomplete.get_completer") as m:
         m.return_value = (
             ["./abcd", "./abce"],
             autocomplete.FilenameCompletion(),
         )
         self.repl.update_completion()
         self.assertEqual(self.repl.list_win_visible, False)
     self.repl.on_tab()
     self.assertEqual(self.repl._current_line, " './abc'")
     self.assertEqual(self.repl.current_match, None)
     self.assertEqual(self.repl.list_win_visible, False)