diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2018-11-17 19:09:54 -0600 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2018-11-17 19:09:54 -0600 |
commit | 830e5cfcea1dc4bc592f1e61d788b6eccc6052c6 (patch) | |
tree | e3d0bc378de8a1f34f711446c426c71f91c9e563 /unitTests.py | |
parent | 905b01bece3a17e952cb11eaa8c9d2d272b27569 (diff) | |
download | pyparsing-git-830e5cfcea1dc4bc592f1e61d788b6eccc6052c6.tar.gz |
Add support for combining unicode_sets using multiple inheritance
Diffstat (limited to 'unitTests.py')
-rw-r--r-- | unitTests.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/unitTests.py b/unitTests.py index 5cb293d..2aff419 100644 --- a/unitTests.py +++ b/unitTests.py @@ -3650,8 +3650,9 @@ class UnicodeTests(ParseTestCase): self.assertTrue(result.asList() == [u'Καλημέρα', ',', u'κόσμε', '!'],
"Failed to parse Greek 'Hello, World!' using pyparsing_unicode.Greek.alphas")
- class Turkish_set(pp.unicode_set):
- _ranges = pp.pyparsing_unicode.Latin1._ranges + pp.pyparsing_unicode.LatinA._ranges
+ # define a custom unicode range using multiple inheritance
+ class Turkish_set(pp.pyparsing_unicode.Latin1, pp.pyparsing_unicode.LatinA):
+ pass
key = pp.Word(Turkish_set.alphas)
value = pp.pyparsing_common.integer | pp.Word(Turkish_set.alphas, Turkish_set.alphanums)
@@ -3667,6 +3668,9 @@ class UnicodeTests(ParseTestCase): print(result.asDict())
self.assertEqual(result.asDict(), {'şehir': 'İzmir', 'ülke': 'Türkiye', 'nüfus': 4279677},
"Failed to parse Turkish key-value pairs")
+ self.assertEqual(len(pp.pyparsing_unicode.CJK.printables), 53760,
+ "failed to construct ranges by merging Chinese, Japanese and Korean")
+ self.assertEqual(len(Turkish_set.printables), 317, "failed to construct ranges by merging Latin1 and LatinA")
class IndentedBlockTest(ParseTestCase):
# parse pseudo-yaml indented text
|