test_pythonrc.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:pythonrc 作者: lonetwin 项目源码 文件源码
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')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号