コード例 #1
0
ファイル: test_parse.py プロジェクト: peopledoc/mlvtools
def test_should_raise_if_script_does_not_exist(work_dir):
    """
       Tests should raise if script does not exist
    """
    with pytest.raises(MlVToolException) as e:
        get_ast_from_file(join(work_dir, 'does_not_exist.py'))
    assert isinstance(e.value.__cause__, IOError)
コード例 #2
0
ファイル: test_parse.py プロジェクト: peopledoc/mlvtools
def test_should_parse_ast_from_file(work_dir):
    """
       Tests should parse ast from string content
    """
    python_content = 'import os\nprint("hello")'
    script_path = join(work_dir, 'script.py')
    with open(script_path, 'w') as fd:
        fd.write(python_content)
    assert get_ast_from_file(script_path)
コード例 #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)