MCPcopy
hub / github.com/scrapy/scrapy / test_open_in_browser

Function test_open_in_browser

tests/test_utils_response.py:18–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16
17
18def test_open_in_browser():
19 url = "http:///www.example.com/some/page.html"
20 body = (
21 b"<html> <head> <title>test page</title> </head> <body>test body</body> </html>"
22 )
23
24 def browser_open(burl: str) -> bool:
25 path = urlparse(burl).path
26 if not path or not Path(path).exists():
27 path = burl.replace("file://", "")
28 bbody = Path(path).read_bytes()
29 assert b'<base href="' + to_bytes(url) + b'">' in bbody
30 return True
31
32 response = HtmlResponse(url, body=body)
33 assert open_in_browser(response, _openfunc=browser_open), "Browser not called"
34
35 resp = Response(url, body=body)
36 with pytest.raises(TypeError):
37 open_in_browser(resp, debug=True) # pylint: disable=unexpected-keyword-arg
38
39
40def test_get_meta_refresh():

Callers

nothing calls this directly

Calls 3

HtmlResponseClass · 0.90
open_in_browserFunction · 0.90
ResponseClass · 0.90

Tested by

no test coverage detected