(self)
| 319 | ] |
| 320 | |
| 321 | def test_xmliter_namespaces_prefix(self): |
| 322 | body = b""" |
| 323 | <?xml version="1.0" encoding="UTF-8"?> |
| 324 | <root> |
| 325 | <h:table xmlns:h="http://www.w3.org/TR/html4/"> |
| 326 | <h:tr> |
| 327 | <h:td>Apples</h:td> |
| 328 | <h:td>Bananas</h:td> |
| 329 | </h:tr> |
| 330 | </h:table> |
| 331 | |
| 332 | <f:table xmlns:f="http://www.w3schools.com/furniture"> |
| 333 | <f:name>African Coffee Table</f:name> |
| 334 | <f:width>80</f:width> |
| 335 | <f:length>120</f:length> |
| 336 | </f:table> |
| 337 | |
| 338 | </root> |
| 339 | """ |
| 340 | response = XmlResponse(url="http://mydummycompany.com", body=body) |
| 341 | my_iter = self.xmliter(response, "table", "http://www.w3.org/TR/html4/", "h") |
| 342 | |
| 343 | node = next(my_iter) |
| 344 | assert len(node.xpath("h:tr/h:td").getall()) == 2 |
| 345 | assert node.xpath("h:tr/h:td[1]/text()").getall() == ["Apples"] |
| 346 | assert node.xpath("h:tr/h:td[2]/text()").getall() == ["Bananas"] |
| 347 | |
| 348 | my_iter = self.xmliter( |
| 349 | response, "table", "http://www.w3schools.com/furniture", "f" |
| 350 | ) |
| 351 | |
| 352 | node = next(my_iter) |
| 353 | assert node.xpath("f:name/text()").getall() == ["African Coffee Table"] |
| 354 | |
| 355 | def test_xmliter_objtype_exception(self): |
| 356 | i = self.xmliter(42, "product") |
nothing calls this directly
no test coverage detected