Upgrade to Python 3.8 + duplicate check when adding in sdp
This commit is contained in:
@@ -39,6 +39,18 @@ def null():
|
||||
def b(operator, left, right):
|
||||
return BinaryNode([], operator, left, right)
|
||||
|
||||
def compare_ast(left, right):
|
||||
left_as_string = ast.dump(left)
|
||||
left_as_string = left_as_string.replace(", ctx=Load()", "")
|
||||
left_as_string = left_as_string.replace(", kind=None", "")
|
||||
|
||||
right_as_string = right if isinstance(right, str) else ast.dump(right)
|
||||
right_as_string = right_as_string.replace(", ctx=Load()", "")
|
||||
right_as_string = right_as_string.replace(", kind=None", "")
|
||||
|
||||
return left_as_string == right_as_string
|
||||
|
||||
|
||||
|
||||
def test_i_can_tokenize():
|
||||
source = "+*-/{}[]() ,;:.?\n\n\r\r\r\nidentifier_0\t \t10.15 10 'string\n' \"another string\"="
|
||||
@@ -213,19 +225,11 @@ def test_i_can_parse_def_concept(text, expected_name, expected_expr):
|
||||
assert isinstance(tree, DefConceptNode)
|
||||
assert tree.name == expected_name
|
||||
if isinstance(tree.body, PythonNode):
|
||||
assert ast.dump(tree.body.ast) == ast.dump(expected_expr)
|
||||
assert compare_ast(tree.body.ast, expected_expr)
|
||||
else:
|
||||
assert tree.body == expected_expr
|
||||
|
||||
|
||||
def compare_ast(left, right):
|
||||
left_as_string = ast.dump(left)
|
||||
left_as_string = left_as_string.replace(", ctx=Load()", "")
|
||||
|
||||
right_as_string = right if isinstance(right, str) else ast.dump(right)
|
||||
right_as_string = right_as_string.replace(", ctx=Load()", "")
|
||||
|
||||
return left_as_string == right_as_string
|
||||
|
||||
|
||||
def test_i_can_parse_complex_def_concept_statement():
|
||||
|
||||
Reference in New Issue
Block a user