mirror of https://github.com/scrapy/scrapy.git
add test
This commit is contained in:
parent
e411ea94eb
commit
a988c4b78b
|
|
@ -1,3 +1,4 @@
|
|||
import codecs
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
|
|
@ -358,6 +359,8 @@ class TextResponseTest(BaseResponseTest):
|
|||
headers={"Content-type": ["text/html; charset=gb2312"]})
|
||||
r7 = self.response_class("http://www.example.com", body=b"\xa8D",
|
||||
headers={"Content-type": ["text/html; charset=gbk"]})
|
||||
r8 = self.response_class("http://www.example.com", body=codecs.BOM_UTF8 + b"\xc2\xa3",
|
||||
headers={"Content-type": ["text/html; charset=cp1251"]})
|
||||
|
||||
self.assertEqual(r1._headers_encoding(), "utf-8")
|
||||
self.assertEqual(r2._headers_encoding(), None)
|
||||
|
|
@ -367,7 +370,10 @@ class TextResponseTest(BaseResponseTest):
|
|||
self.assertEqual(r3._declared_encoding(), "cp1252")
|
||||
self.assertEqual(r4._headers_encoding(), None)
|
||||
self.assertEqual(r5._headers_encoding(), None)
|
||||
self.assertEqual(r8._headers_encoding(), "cp1251")
|
||||
self.assertEqual(r8._declared_encoding(), "utf-8")
|
||||
self._assert_response_encoding(r5, "utf-8")
|
||||
self._assert_response_encoding(r8, "utf-8")
|
||||
assert r4._body_inferred_encoding() is not None and r4._body_inferred_encoding() != 'ascii'
|
||||
self._assert_response_values(r1, 'utf-8', "\xa3")
|
||||
self._assert_response_values(r2, 'utf-8', "\xa3")
|
||||
|
|
|
|||
Loading…
Reference in New Issue