MCPcopy
hub / github.com/scrapy/scrapy / test_inject_base_url

Function test_inject_base_url

tests/test_utils_response.py:168–181  ·  view source on GitHub ↗
(body: bytes)

Source from the content-addressed store, hash-verified

166 ],
167)
168def test_inject_base_url(body: bytes) -> None:
169 url = "http://www.example.com"
170
171 def check_base_url(burl):
172 path = urlparse(burl).path
173 if not path or not Path(path).exists():
174 path = burl.replace("file://", "")
175 bbody = Path(path).read_bytes()
176 assert bbody.count(b'><base href="' + to_bytes(url) + b'">') == 1
177 assert b"<head" in bbody
178 return True
179
180 resp = HtmlResponse(url, body=body)
181 assert open_in_browser(resp, _openfunc=check_base_url)
182
183
184def test_open_in_browser_redos_comment():

Callers

nothing calls this directly

Calls 2

HtmlResponseClass · 0.90
open_in_browserFunction · 0.90

Tested by

no test coverage detected