Beispiel #1
0
    def test_classes_handling(self):
        doc = Doc()

        with doc.tag("main", klass="bad_class primary light"):
            with doc.tag("div", id="c", klass="inside", style="B"):
                with doc.tag('p', klass="paragraph"):
                    doc.text("some")
                    doc.text("text")
                    doc.discard_class("paragraph")
                doc.toggle_class("option")

            doc.add_class("secondary")
            doc.discard_class("bad_class")
            doc.toggle_class("light")

        assert str(doc) == """\
Beispiel #2
0
 def test_toggling(self):
     doc = Doc()
     with doc.tag("one", klass="B A C"):
         doc.text("text")
         doc.toggle_class("B B D")
     assert str(doc) == "<one class='A C D'>text</one>"