def test_compiler_compile(patch, magic): patch.object(Compiler, 'generate') patch.object(JSONCompiler, 'compile') tree = magic() result = Compiler.compile(tree, story=None, features=None) Compiler.generate.assert_called_with(tree, None) JSONCompiler.compile.assert_called_with(Compiler.generate()) assert result == JSONCompiler.compile()
def test_compiler_compile(patch, magic): patch.object(Compiler, "generate", return_value=("tree", "sem")) patch.object(JSONCompiler, "compile") tree = magic() story = magic() result = Compiler.compile(tree, story=story) Compiler.generate.assert_called_with(tree, story.context, scope=None) JSONCompiler.compile.assert_called_with("tree") assert result.output() == JSONCompiler.compile() assert result.module() == "sem" assert result.backend == "json"