MCPcopy
hub / github.com/scrapy/scrapy / test_follow_encoding

Method test_follow_encoding

tests/test_http_response_text.py:373–398  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

371 )
372
373 def test_follow_encoding(self):
374 resp1 = self.response_class(
375 "http://example.com",
376 encoding="utf8",
377 body='<html><body><a href="foo?привет">click me</a></body></html>'.encode(),
378 )
379 req = self._assert_followed_url(
380 resp1.css("a")[0],
381 "http://example.com/foo?%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82",
382 response=resp1,
383 )
384 assert req.encoding == "utf8"
385
386 resp2 = self.response_class(
387 "http://example.com",
388 encoding="cp1251",
389 body='<html><body><a href="foo?привет">click me</a></body></html>'.encode(
390 "cp1251"
391 ),
392 )
393 req = self._assert_followed_url(
394 resp2.css("a")[0],
395 "http://example.com/foo?%EF%F0%E8%E2%E5%F2",
396 response=resp2,
397 )
398 assert req.encoding == "cp1251"
399
400 def test_follow_flags(self):
401 res = self.response_class("http://example.com/")

Callers

nothing calls this directly

Calls 2

_assert_followed_urlMethod · 0.80
cssMethod · 0.45

Tested by

no test coverage detected