@@ -11,6 +11,7 @@ |
|
|
11 |
11 |
import operator |
12 |
12 |
import struct |
13 |
13 |
import sys |
|
14 |
+import unicodedata |
14 |
15 |
import unittest |
15 |
16 |
import warnings |
16 |
17 |
from test import support, string_tests |
@@ -615,11 +616,21 @@ def test_isspace(self): |
|
|
615 |
616 |
self.checkequalnofix(True, '\u2000', 'isspace') |
616 |
617 |
self.checkequalnofix(True, '\u200a', 'isspace') |
617 |
618 |
self.checkequalnofix(False, '\u2014', 'isspace') |
618 |
|
-# apparently there are no non-BMP spaces chars in Unicode 6 |
|
619 |
+# There are no non-BMP whitespace chars as of Unicode 12. |
619 |
620 |
for ch in ['\U00010401', '\U00010427', '\U00010429', '\U0001044E', |
620 |
621 |
'\U0001F40D', '\U0001F46F']: |
621 |
622 |
self.assertFalse(ch.isspace(), '{!a} is not space.'.format(ch)) |
622 |
623 |
|
|
624 |
+@support.requires_resource('cpu') |
|
625 |
+def test_isspace_invariant(self): |
|
626 |
+for codepoint in range(sys.maxunicode + 1): |
|
627 |
+char = chr(codepoint) |
|
628 |
+bidirectional = unicodedata.bidirectional(char) |
|
629 |
+category = unicodedata.category(char) |
|
630 |
+self.assertEqual(char.isspace(), |
|
631 |
+ (bidirectional in ('WS', 'B', 'S') |
|
632 |
+or category == 'Zs')) |
|
633 |
+ |
623 |
634 |
def test_isalnum(self): |
624 |
635 |
super().test_isalnum() |
625 |
636 |
for ch in ['\U00010401', '\U00010427', '\U00010429', '\U0001044E', |