def test_more_elements_in_tag(self): path = PathInfo().append("html").append("body").append("div") self.assertEqual(path.dom, "html.body.div") self.assertEqual(path.xpath, "/html[1]/body[1]/div[1]") path.pop() self.assertEqual(path.dom, "html.body") self.assertEqual(path.xpath, "/html[1]/body[1]") path.append("span") self.assertEqual(path.dom, "html.body.span") self.assertEqual(path.xpath, "/html[1]/body[1]/span[1]") path.pop() self.assertEqual(path.dom, "html.body") self.assertEqual(path.xpath, "/html[1]/body[1]") path.append("pre") self.assertEqual(path.dom, "html.body.pre") self.assertEqual(path.xpath, "/html[1]/body[1]/pre[1]")
def test_removing_element(self): path = PathInfo().append("html").append("body") path.append("div").append("a").pop() self.assertEqual(path.dom, "html.body.div") self.assertEqual(path.xpath, "/html[1]/body[1]/div[1]") path.pop() self.assertEqual(path.dom, "html.body") self.assertEqual(path.xpath, "/html[1]/body[1]")