def test_data_replace(self): element = Element("div") element.data = {"old": "xxx", "foo": "old-value"} # type: ignore element.data = {"foo": "bar", "abc": "def"} # type: ignore assert_equal( [b'<div data-abc="def" data-foo="bar">', b"</div>"], list(iter(element)), )
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"))
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"))
def test_data_clear(self): element = Element("div") element.data = {"old": "xxx", "foo": "old-value"} # type: ignore element.data.clear() assert_equal([b"<div>", b"</div>"], list(iter(element)))
def test_data_replace(self): element = Element("div") element.data = {"old": "xxx", "foo": "old-value"} element.data = {"foo": "bar", "abc": "def"} assert_equal([b'<div data-abc="def" data-foo="bar">', b"</div>"], list(iter(element)))
def test_data_clear(self): element = Element("div") element.data = {"old": "xxx", "foo": "old-value"} element.data.clear() assert_equal([b'<div>', b"</div>"], list(iter(element)))