Skip to content

Commit

Permalink
added test for code processing
Browse files Browse the repository at this point in the history
  • Loading branch information
nucccc committed Dec 12, 2023
1 parent 576dd67 commit 616c23f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/test_code_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
func_codelines,
process_code,
indentation_pattern,
ASTWithoutBody
ASTWithoutBody,
InvalidIndentation
)
from markarth.convert.collect.mod_collect import collect_func_defs

Expand Down Expand Up @@ -61,4 +62,17 @@ def test_indentation_pattern_ast_without_body():
func_ast = ast_nodes.body[0]

with pytest.raises(ASTWithoutBody) as ast_without_body:
indentation_pattern(func_ast, codelines)
indentation_pattern(func_ast, codelines)


def test_indentation_pattern_invalid_indentation_level():
code = '''
def f():
this_code_is_nah = None
'''

ast_nodes, codelines = process_code(code)
func_ast = ast_nodes.body[0]

with pytest.raises(InvalidIndentation) as ast_without_body:
indentation_pattern(func_ast, codelines, indent_level = 2)

0 comments on commit 616c23f

Please sign in to comment.