aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Lamy <ronan.lamy@gmail.com>2017-02-23 16:43:40 +0000
committerRonan Lamy <ronan.lamy@gmail.com>2017-02-23 16:43:40 +0000
commit9019d1612478e291498a60d81474a8a803a29743 (patch)
tree16ec06eb6be0a3265573239de362c8d46ec0c143 /extra_tests
parentmerge heads (diff)
downloadpypy-9019d1612478e291498a60d81474a8a803a29743.tar.gz
pypy-9019d1612478e291498a60d81474a8a803a29743.tar.bz2
pypy-9019d1612478e291498a60d81474a8a803a29743.zip
Add extra_test for issue 2289 (backport of 88ef793308eb)
Diffstat (limited to 'extra_tests')
-rw-r--r--extra_tests/README.txt5
-rw-r--r--extra_tests/pytest.ini0
-rw-r--r--extra_tests/test_unicode.py34
3 files changed, 39 insertions, 0 deletions
diff --git a/extra_tests/README.txt b/extra_tests/README.txt
new file mode 100644
index 0000000000..8a1424e1a8
--- /dev/null
+++ b/extra_tests/README.txt
@@ -0,0 +1,5 @@
+The tests in this directory are a complement to lib-python/3/test/.
+
+They are meant to run on top of a compiled pypy3 or CPython3.5 in an
+environment containing at least pytest and hypothesis, using a command like
+'pytest extra_tests/'.
diff --git a/extra_tests/pytest.ini b/extra_tests/pytest.ini
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/extra_tests/pytest.ini
diff --git a/extra_tests/test_unicode.py b/extra_tests/test_unicode.py
new file mode 100644
index 0000000000..fece11caea
--- /dev/null
+++ b/extra_tests/test_unicode.py
@@ -0,0 +1,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)