def test_path_completions(): p = Parser() if not os.name == 'nt': code = '/usr/bi' assert 'bin/' in p.parse_code(code)['path_matches'] code = '~/.bashr' assert 'bashrc' in p.parse_code(code)['path_matches'] for f in os.listdir('.'): if f.startswith('.'): if os.path.isdir(f): assert f[1:] + os.sep in p.parse_code('.')['path_matches'], f else: assert f[1:] in p.parse_code('.')['path_matches']
def test_parser(): p = Parser() info = p.parse_code('import nump') assert info['help_obj'] == info['obj'] == 'nump' assert p.parse_code('%python impor', 0, 10)['magic']['name'] == 'python' assert p.parse_code('oct(a,')['help_obj'] == 'oct' assert p.parse_code('! ls')['magic']['name'] == 'shell' info = p.parse_code('%help %lsmagic', 0, 10) assert info['help_obj'] == '%lsmagic' assert info['obj'] == '%lsm' info = p.parse_code('%%python\nprint("hello, world!",') assert info['help_obj'] == 'print' info = p.parse_code('%lsmagic') assert info['help_obj'] == '%lsmagic' info = p.parse_code('%') assert info['magic']['type'] == 'line'
def test_complete0(): p = Parser() info = p.parse_code('abcdefghijklmnop', 0, 4) assert info['obj'] == 'abcd', info
def test_scheme_parser(): function_call_regex = r'\(([^\d\W][\w\.]*)[^\)\()]*\Z' p = Parser(function_call_regex=function_call_regex) info = p.parse_code('(oct a b ') assert info['help_obj'] == 'oct'