def test_completer(self):
completer = self.pymp.improved_rlcompleter()
rl = pythonrc.readline
# - no leading characters
with patch.object(rl, 'get_line_buffer', return_value='\t'):
self.assertEqual(completer('\t', 0), ' ')
# - keyword completion
with patch.object(rl, 'get_line_buffer', return_value='imp\t'):
self.assertEqual(completer('imp', 0), 'import ')
# - module name completion
with patch.object(rl, 'get_line_buffer', return_value='from '):
self.assertIn(completer('th', 0), ('this', 'threading'))
self.assertIn(completer('th', 1), ('this', 'threading'))
# - pathname completion
with patch.object(rl, 'get_line_buffer', return_value='./p'):
self.assertEqual(completer('./py', 0), './pythonrc.py')
评论列表
文章目录