예제 #1
0
    def test_parse_codeblock(self):
        b = CodeBlock()
        b.add_dependency("test", "blah")
        b.write_line("if 1:")
        b.write_line("do()", 1)
        n, v = parse_code("""
if 2:
    $doit
""", None, doit=b)

        self.assertEqual(str(n), "if 2:\n    if 1:\n        do()")
        self.assertTrue("test" in n.get_dependencies())
예제 #2
0
 def test_codeblock_deps(self):
     a = CodeBlock()
     a.add_dependency("a", object())
     self.assertRaises(ValueError, a.add_dependency, "a", object())
예제 #3
0
 def test_codeblock_print(self):
     f = StringIO()
     a = CodeBlock()
     a.write_line("abc")
     a.pprint(f)
     self.assertEqual(f.getvalue(), "abc\n")
예제 #4
0
 def test_codeblock(self):
     a = CodeBlock("foo")
     self.assertEqual(str(a), "foo")
     a.write_lines(["1", "2"], 0)
     self.assertEqual(str(a), "foo\n1\n2")