Exemplo n.º 1
0
 def test_data_external(self):
     element = Element("div")
     element.set_attribute("data-foo", "bar")
     assert_equal("bar", element.data["foo"])
     element.data["xyz"] = "abc"
     assert_equal("abc", element.get_attribute("data-xyz"))
     element.data.clear()
     assert_is_none(element.get_attribute("data-foo"))
     element.set_attribute("data-old", "")
     element.data = {}  # type: ignore
     assert_is_none(element.get_attribute("data-old"))
Exemplo n.º 2
0
 def test_data_external(self):
     element = Element("div")
     element.set_attribute("data-foo", "bar")
     assert_equal("bar", element.data["foo"])
     element.data["xyz"] = "abc"
     assert_equal("abc", element.get_attribute("data-xyz"))
     element.data.clear()
     assert_is_none(element.get_attribute("data-foo"))
     element.set_attribute("data-old", "")
     element.data = {}
     assert_is_none(element.get_attribute("data-old"))
Exemplo n.º 3
0
 def test_remove_attribute(self):
     element = Element("div")
     element.remove_attribute("foo")
     element.set_attribute("foo", "bar")
     element.remove_attribute("foo")
     assert_is_none(element.get_attribute("foo"))
     assert_equal([b"<div>", b"</div>"], list(iter(element)))
Exemplo n.º 4
0
 def test_remove_attribute(self):
     element = Element("div")
     element.remove_attribute("foo")
     element.set_attribute("foo", "bar")
     element.remove_attribute("foo")
     assert_is_none(element.get_attribute("foo"))
     assert_equal([b'<div>', b"</div>"], list(iter(element)))
Exemplo n.º 5
0
 def test_get_attribute(self):
     element = Element("div")
     assert_is_none(element.get_attribute("foo"))
     assert_equal("XXX", element.get_attribute("foo", default="XXX"))
Exemplo n.º 6
0
 def test_attributes(self):
     element = Element("div")
     element.set_attribute("foo", "bar")
     assert_equal("bar", element.get_attribute("foo"))
     assert_equal([b'<div foo="bar">', b"</div>"], list(iter(element)))
Exemplo n.º 7
0
 def test_get_attribute(self):
     element = Element("div")
     assert_is_none(element.get_attribute("foo"))
     assert_equal("XXX", element.get_attribute("foo", default="XXX"))
Exemplo n.º 8
0
 def test_attributes(self):
     element = Element("div")
     element.set_attribute("foo", "bar")
     assert_equal("bar", element.get_attribute("foo"))
     assert_equal([b'<div foo="bar">', b"</div>"], list(iter(element)))