MCPcopy
hub / github.com/scrapy/scrapy / test_flavor_detection

Method test_flavor_detection

tests/test_selector.py:49–61  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

47 assert url == sel.root.base
48
49 def test_flavor_detection(self):
50 text = b'<div><img src="a.jpg"><p>Hello</div>'
51 sel = Selector(XmlResponse("http://example.com", body=text, encoding="utf-8"))
52 assert sel.type == "xml"
53 assert sel.xpath("//div").getall() == [
54 '<div><img src="a.jpg"><p>Hello</p></img></div>'
55 ]
56
57 sel = Selector(HtmlResponse("http://example.com", body=text, encoding="utf-8"))
58 assert sel.type == "html"
59 assert sel.xpath("//div").getall() == [
60 '<div><img src="a.jpg"><p>Hello</p></div>'
61 ]
62
63 def test_http_header_encoding_precedence(self):
64 # '\xa3' = pound symbol in unicode

Callers

nothing calls this directly

Calls 4

SelectorClass · 0.90
XmlResponseClass · 0.90
HtmlResponseClass · 0.90
xpathMethod · 0.45

Tested by

no test coverage detected