Skip to content

Commit c202855

Browse files
committed
Add tests
1 parent 14216ec commit c202855

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/test_misc.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import pytest
2+
from scrapy.http.headers import Headers
3+
4+
from scrapy_playwright.handler import _get_response_encoding
5+
6+
7+
@pytest.mark.asyncio
8+
async def test_get_response_encoding():
9+
assert (
10+
_get_response_encoding(
11+
headers=Headers({"content-type": "text/html; charset=UTF-8"}),
12+
body="",
13+
)
14+
== "utf-8"
15+
)
16+
assert (
17+
_get_response_encoding(
18+
headers=Headers(),
19+
body="""<!doctype html>
20+
<html lang="cn">
21+
<head>
22+
<meta charset="gb2312">
23+
</head>
24+
</html>
25+
""",
26+
)
27+
== "gb18030"
28+
)
29+
assert _get_response_encoding(headers=Headers(), body="") is None

0 commit comments

Comments
 (0)