Exemplo n.º 1
0
 def test_append_extend(self):
     generator = JoinGenerator(u"!", [u"foo"])
     generator.append(u"bar")
     sub_generator = ChildGenerator()
     sub_generator.append(u"baz")
     generator.extend([sub_generator])
     assert_equal([b"foo", b"!", b"bar", b"!", b"baz"],
                  list(iter(generator)))
Exemplo n.º 2
0
 def test_append_extend(self):
     generator = HTMLJoinGenerator(u"!", [u"foo"])
     generator.append(u"<bar>")
     sub_generator = ChildGenerator()
     sub_generator.append(u"<baz>")
     generator.extend([sub_generator])
     assert_equal([b"foo", b"!", b"&lt;bar&gt;", b"!", b"<baz>"],
                  list(iter(generator)))
Exemplo n.º 3
0
 def test_remove_generator(self):
     sub_generator = Generator()
     generator = ChildGenerator()
     generator.append("foo")
     generator.append(sub_generator)
     generator.remove(sub_generator)
     assert_equal([b"foo"], list(iter(generator)))
Exemplo n.º 4
0
 def test_remove_string(self):
     generator = ChildGenerator()
     generator.append("foo")
     generator.append("bar")
     generator.remove("foo")
     assert_equal([b"bar"], list(iter(generator)))
Exemplo n.º 5
0
 def test_extend(self):
     generator = ChildGenerator()
     generator.append(u"c1")
     generator.extend([_TestingGenerator([u"c2", u"c3"]), u"c4"])
     assert_equal([b"c1", b"c2", b"c3", b"c4"], list(iter(generator)))
Exemplo n.º 6
0
 def test_glue_is_generator(self):
     glue = ChildGenerator()
     glue.append(u"<")
     generator = JoinGenerator(glue, [u"foo", u"bar", u"baz"])
     assert_equal([b"foo", b"<", b"bar", b"<", b"baz"],
                  list(iter(generator)))
Exemplo n.º 7
0
 def test_children(self):
     generator = ChildGenerator()
     generator.append("Foo")
     assert_equal(["Foo"], generator.children)
     generator.children.append("Bar")
     assert_equal(["Foo"], generator.children)
Exemplo n.º 8
0
 def test_empty(self):
     generator = ChildGenerator()
     generator.append(u"c1")
     generator.extend([u"c2", u"c3", NullGenerator()])
     generator.empty()
     assert_equal([], list(iter(generator)))
Exemplo n.º 9
0
 def test_len(self):
     generator = ChildGenerator()
     generator.append(u"c1")
     generator.extend([u"c2", u"c3", NullGenerator()])
     assert_equal(4, len(generator))
Exemplo n.º 10
0
 def test_remove__not_found(self):
     generator = ChildGenerator()
     generator.append("foo")
     with assert_raises(ValueError):
         generator.remove("abc")