예제 #1
0
def test_script_must_not_be_ast_equals(script_base, diff_script_content):
    """
        Test ast tree are not equal if diff docstring or statements
    """
    base_ast = get_ast(script_base)
    diff_ast = get_ast(diff_script_content)

    assert not is_ast_equal(base_ast, diff_ast)
예제 #2
0
def test_script_must_be_ast_equals(script_base, diff_script_content):
    """
        Test ast tree are equal even if diff on blank lines, whitespaces and comments
    """
    base_ast = get_ast(script_base)
    diff_ast = get_ast(diff_script_content)

    assert is_ast_equal(base_ast, diff_ast)
예제 #3
0
def compare(notebook_path: str, script_path: str, conf: MlVToolConf) -> bool:
    """
        Compare the script obtained by notebook conversion using ipynb_to_python
        with the actual script.
    """
    generated_script = get_converted_script(notebook_path, conf)
    generated_ast = get_ast(generated_script, name=notebook_path)

    script_ast = get_ast_from_file(script_path)

    return is_ast_equal(generated_ast, script_ast)