summaryrefslogtreecommitdiff
path: root/unitTests.py
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@austin.rr.com>2018-11-17 19:09:54 -0600
committerPaul McGuire <ptmcg@austin.rr.com>2018-11-17 19:09:54 -0600
commit830e5cfcea1dc4bc592f1e61d788b6eccc6052c6 (patch)
treee3d0bc378de8a1f34f711446c426c71f91c9e563 /unitTests.py
parent905b01bece3a17e952cb11eaa8c9d2d272b27569 (diff)
downloadpyparsing-git-830e5cfcea1dc4bc592f1e61d788b6eccc6052c6.tar.gz
Add support for combining unicode_sets using multiple inheritance
Diffstat (limited to 'unitTests.py')
-rw-r--r--unitTests.py8
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