本文整理汇总了Python中tools.check_parse函数的典型用法代码示例。如果您正苦于以下问题:Python check_parse函数的具体用法?Python check_parse怎么用?Python check_parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_parse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_multilline_no_transform
def test_multilline_no_transform():
# no subprocess transformations happen here since all variables are known
code = 'ls = 1\nl = 1\nls -l\n'
tree = check_parse(code)
lsnode = tree.body[2]
assert 3 == min_line(lsnode)
assert isinstance(lsnode.value, BinOp)
示例2: test_bad_indent
def test_bad_indent():
code = ('if True:\n'
'x = 1\n')
with pytest.raises(SyntaxError):
check_parse(code)
示例3: test_command_in_func_with_comment
def test_command_in_func_with_comment():
code = "def f():\n" " echo hello # comment\n"
assert check_parse(code)
示例4: test_indent_with_empty_line
def test_indent_with_empty_line():
code = "if True:\n" "\n" " some_command for_sub_process_mode\n"
assert check_parse(code)
示例5: test_bad_indent
def test_bad_indent():
code = "if True:\n" "x = 1\n"
with pytest.raises(SyntaxError):
check_parse(code)
示例6: test_lookup_anon_alias
def test_lookup_anon_alias():
code = 'echo "hi" | @(lambda a, s=None: a[0]) foo bar baz\n'
assert check_parse(code)
示例7: test_echo_star_with_semi
def test_echo_star_with_semi():
assert check_parse("echo * spam ; ![echo eggs]\n")
示例8: test_which_ls
def test_which_ls():
assert check_parse("which ls")
示例9: test_multilline_num
def test_multilline_num(line1):
code = line1 + '\nls -l\n'
tree = check_parse(code)
lsnode = tree.body[1]
assert 2 == min_line(lsnode)
assert isinstance(lsnode.value, Call)
示例10: test_echo_comma
def test_echo_comma():
code = 'echo ,\n'
assert check_parse(code)
示例11: test_good_rhs_subproc
def test_good_rhs_subproc():
# nonsense but parsebale
code = 'str().split() | ![grep exit]\n'
check_parse(code)
示例12: test_command_in_func_with_comment
def test_command_in_func_with_comment():
code = ('def f():\n'
' echo hello # comment\n')
assert check_parse(code)
示例13: test_command_in_func
def test_command_in_func():
code = ('def f():\n'
' echo hello\n')
assert check_parse(code)
示例14: test_indent_with_empty_line
def test_indent_with_empty_line():
code = ('if True:\n'
'\n'
' some_command for_sub_process_mode\n')
assert check_parse(code)
示例15: test_two_echo_line_cont
def test_two_echo_line_cont(code):
assert check_parse(code)