-
Notifications
You must be signed in to change notification settings - Fork 243
/
test_unicode.py
46 lines (33 loc) · 1.47 KB
/
test_unicode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import pytest
from bleach import clean, linkify
def test_japanese_safe_simple():
assert clean("ヘルプとチュートリアル") == "ヘルプとチュートリアル"
assert linkify("ヘルプとチュートリアル") == "ヘルプとチュートリアル"
def test_japanese_strip():
assert clean("<em>ヘルプとチュートリアル</em>") == "<em>ヘルプとチュートリアル</em>"
assert (
clean("<span>ヘルプとチュートリアル</span>")
== "<span>ヘルプとチュートリアル</span>"
)
def test_russian_simple():
assert clean("Домашняя") == "Домашняя"
assert linkify("Домашняя") == "Домашняя"
def test_mixed():
assert clean("Домашняяヘルプとチュートリアル") == "Домашняяヘルプとチュートリアル"
def test_mixed_linkify():
assert (
linkify("Домашняя http://example.com ヘルプとチュートリアル")
== 'Домашняя <a href="http://example.com" rel="nofollow">http://example.com</a> ヘルプとチュートリアル'
)
@pytest.mark.parametrize(
"uri",
[
"http://éxámplé.com/",
"http://éxámplé.com/íàñá/",
"http://éxámplé.com/íàñá/?foo=bar",
"http://éxámplé.com/íàñá/?fóo=bár",
],
)
def test_url_utf8(uri):
"""Allow UTF8 characters in URLs themselves."""
assert linkify(uri) == f'<a href="{uri}" rel="nofollow">{uri}</a>'