def setUp(self): lib = ir.TemplateNode( defs=[ir.DefNode( 'evenness(n)', ir.IfNode( 'n % 2 == 0', ir.TextNode('even')), ir.ElseNode( ir.TextNode('odd'))), ir.DefNode( 'half_evenness(n)', ir.TextNode(' half of '), ir.ExprNode('n'), ir.TextNode(' is '), ir.ExprNode('evenness(n/2)'))]) tpl = ir.TemplateNode( defs=[ir.DefNode( '__main__()', ir.ImportNode( 'lib.txt', 'simple_function'), ir.ForNode( 'i in range(4)', ir.ExprNode('i'), ir.TextNode(' is '), ir.ExprNode('simple_function.evenness(i)'), ir.ExprNode('simple_function.half_evenness(i)'), ir.TextNode('\n')))]) loader = kajiki.loader.MockLoader({ 'lib.txt': kajiki.template.from_ir(lib), 'tpl.txt': kajiki.template.from_ir(tpl)}) self.tpl = loader.import_('tpl.txt')
def setUp(self): self.tpl = ir.TemplateNode( defs=[ir.DefNode( '__main__()', ir.ForNode( 'i in range(2)', ir.ExprNode('i'), ir.TextNode(' is '), ir.SwitchNode( 'i % 2', ir.CaseNode( '0', ir.TextNode('even\n')), ir.ElseNode( ir.TextNode('odd\n')))))])
def setUp(self): self.tpl = ir.TemplateNode(defs=[ ir.DefNode( "__main__()", ir.ForNode( "i in range(2)", ir.ExprNode("i"), ir.TextNode(" is "), ir.SwitchNode( "i % 2", ir.CaseNode("0", ir.TextNode("even\n")), ir.ElseNode(ir.TextNode("odd\n")), ), ), ) ])
def setUp(self): self.tpl = ir.TemplateNode( defs=[ir.DefNode( 'evenness(n)', ir.IfNode( 'n % 2 == 0', ir.TextNode('even')), ir.ElseNode( ir.TextNode('odd'))), ir.DefNode( '__main__()', ir.ForNode( 'i in range(2)', ir.ExprNode('i'), ir.TextNode(' is '), ir.ExprNode('evenness(i)'), ir.TextNode('\n')))])
def setUp(self): self.tpl = ir.TemplateNode(defs=[ ir.DefNode( "evenness(n)", ir.IfNode("n % 2 == 0", ir.TextNode("even")), ir.ElseNode(ir.TextNode("odd")), ), ir.DefNode( "__main__()", ir.ForNode( "i in range(2)", ir.ExprNode("i"), ir.TextNode(" is "), ir.ExprNode("evenness(i)"), ir.TextNode("\n"), ), ), ])
def setUp(self): self.tpl = ir.TemplateNode( defs=[ir.DefNode( 'quote(caller, speaker)', ir.ForNode( 'i in range(2)', ir.TextNode('Quoth '), ir.ExprNode('speaker'), ir.TextNode(', "'), ir.ExprNode('caller(i)'), ir.TextNode('."\n'))), ir.DefNode( '__main__()', ir.CallNode( '$caller(n)', "quote($caller, 'the raven')", ir.TextNode('Nevermore '), ir.ExprNode('n')))])
def setup_class(self): if sys.version_info < (3, 10): pytest.skip("pep622 unavailable before python3.10") self.tpl = ir.TemplateNode(defs=[ ir.DefNode( "__main__()", ir.ForNode( "i in range(2)", ir.ExprNode("i"), ir.TextNode(" is "), ir.MatchNode( "i % 2", ir.MatchCaseNode("0", ir.TextNode("even\n")), ir.MatchCaseNode("_", ir.TextNode("odd\n")), ), ), ) ])
def setUp(self): self.tpl = ir.TemplateNode(defs=[ ir.DefNode( "quote(caller, speaker)", ir.ForNode( "i in range(2)", ir.TextNode("Quoth "), ir.ExprNode("speaker"), ir.TextNode(', "'), ir.ExprNode("caller(i)"), ir.TextNode('."\n'), ), ), ir.DefNode( "__main__()", ir.CallNode( "$caller(n)", "quote($caller, 'the raven')", ir.TextNode("Nevermore "), ir.ExprNode("n"), ), ), ])
def setUp(self): lib = ir.TemplateNode(defs=[ ir.DefNode( "evenness(n)", ir.IfNode("n % 2 == 0", ir.TextNode("even")), ir.ElseNode(ir.TextNode("odd")), ), ir.DefNode( "half_evenness(n)", ir.TextNode(" half of "), ir.ExprNode("n"), ir.TextNode(" is "), ir.ExprNode("evenness(n/2)"), ), ]) tpl = ir.TemplateNode(defs=[ ir.DefNode( "__main__()", ir.ImportNode("lib.txt", "simple_function"), ir.ForNode( "i in range(4)", ir.ExprNode("i"), ir.TextNode(" is "), ir.ExprNode("simple_function.evenness(i)"), ir.ExprNode("simple_function.half_evenness(i)"), ir.TextNode("\n"), ), ) ]) loader = kajiki.loader.MockLoader({ "lib.txt": kajiki.template.from_ir(lib), "tpl.txt": kajiki.template.from_ir(tpl), }) self.tpl = loader.import_("tpl.txt")