Exemple #1
0
 def test_remove_raw_generator(self):
     sub_generator = Generator()
     generator = HTMLChildGenerator()
     generator.append(sub_generator)
     generator.append("foo")
     generator.remove_raw(sub_generator)
     assert_equal([b"foo"], list(iter(generator)))
Exemple #2
0
 def test_children(self):
     generator = HTMLChildGenerator()
     generator.append("Foo")
     generator.append("<tag>")
     assert_equal(["Foo", "&lt;tag&gt;"], generator.children)
     generator.children.append("Bar")
     assert_equal(["Foo", "&lt;tag&gt;"], generator.children)
Exemple #3
0
 def test_children_readonly(self):
     generator = HTMLChildGenerator()
     generator.append("Foo")
     generator.children.append("Bar")
     assert_equal(["Foo"], generator.children)
Exemple #4
0
 def test_empty(self):
     generator = HTMLChildGenerator()
     generator.append(u"c1")
     generator.extend([u"c2", u"c3", NullGenerator()])
     generator.empty()
     assert_equal([], list(iter(generator)))
Exemple #5
0
 def test_len(self):
     generator = HTMLChildGenerator()
     generator.append(u"c1")
     generator.extend([u"c2", u"c3", NullGenerator()])
     assert_equal(4, len(generator))
Exemple #6
0
 def test_remove_raw(self):
     generator = HTMLChildGenerator()
     generator.extend_raw(["foo", "bar", "lower < than"])
     generator.remove_raw("foo")
     generator.remove_raw("lower < than")
     assert_equal([b"bar"], list(iter(generator)))
Exemple #7
0
 def test_remove_raw_not_found(self):
     generator = HTMLChildGenerator()
     generator.extend(["foo", "bar"])
     with assert_raises(ValueError):
         generator.remove_raw("baz")
Exemple #8
0
 def test_extend_raw(self):
     generator = HTMLChildGenerator()
     generator.append(u"c1")
     generator.extend_raw([_TestingGenerator([u"c&2", u"c3"]), u"<c4>"])
     assert_equal([b"c1", b"c&2", b"c3", b"<c4>"], list(iter(generator)))
Exemple #9
0
 def test_append_raw(self):
     generator = HTMLChildGenerator()
     generator.append_raw(u"c1&c2")
     generator.append_raw(_TestingGenerator([u"c3", u"<c4>"]))
     assert_equal([b"c1&c2", b"c3", b"<c4>"], list(iter(generator)))
Exemple #10
0
 def __init__(self, element_name):
     super(Element, self).__init__(element_name)
     self.children = HTMLChildGenerator()