forked from ethanchewy/PythonBuddy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_unicode.py
More file actions
34 lines (31 loc) · 1.02 KB
/
test_unicode.py
File metadata and controls
34 lines (31 loc) · 1.02 KB
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
import pytest
from hypothesis import strategies as st
from hypothesis import given, settings, example
from unicodedata import normalize
# For every (n1, n2, n3) triple, applying n1 then n2 must be the same
# as applying n3.
# Reference: http://unicode.org/reports/tr15/#Design_Goals
compositions = [
('NFC', 'NFC', 'NFC'),
('NFC', 'NFD', 'NFD'),
('NFC', 'NFKC', 'NFKC'),
('NFC', 'NFKD', 'NFKD'),
('NFD', 'NFC', 'NFC'),
('NFD', 'NFD', 'NFD'),
('NFD', 'NFKC', 'NFKC'),
('NFD', 'NFKD', 'NFKD'),
('NFKC', 'NFC', 'NFKC'),
('NFKC', 'NFD', 'NFKD'),
('NFKC', 'NFKC', 'NFKC'),
('NFKC', 'NFKD', 'NFKD'),
('NFKD', 'NFC', 'NFKC'),
('NFKD', 'NFD', 'NFKD'),
('NFKD', 'NFKC', 'NFKC'),
('NFKD', 'NFKD', 'NFKD'),
]
@pytest.mark.parametrize('norm1, norm2, norm3', compositions)
@settings(max_examples=1000)
@example(s=u'---\uafb8\u11a7---') # issue 2289
@given(s=st.text())
def test_composition(s, norm1, norm2, norm3):
assert normalize(norm2, normalize(norm1, s)) == normalize(norm3, s)