diff options
author | Adrian Edwards <17362949+MoralCode@users.noreply.github.com> | 2021-09-02 12:00:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-02 14:00:07 -0500 |
commit | 61a5088e57fccd2568b20e7acda44834325de545 (patch) | |
tree | 9c6318d8880194be3723eca198d5486fe22fc4c8 /tests | |
parent | 2753016857ac796bfda053f7965cf121a85fe932 (diff) | |
download | pyparsing-git-61a5088e57fccd2568b20e7acda44834325de545.tar.gz |
add a caseless parameter to the CloseMatch class (#281)
* add tests for caseless close match
* update CloseMatch to include a caseless parameter
* update CHANGES file
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_unit.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_unit.py b/tests/test_unit.py index e633d64..57322ec 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -5857,6 +5857,38 @@ class Test02_WithoutPackrat(ppt.TestParseResultsAsserts, TestCase): else ("no match", "match")[r[1].mismatches == exp], ) + def testCloseMatchCaseless(self): + + searchseq = pp.CloseMatch("ATCATCGAATGGA", 2, caseless=True) + + _, results = searchseq.runTests( + """ + atcatcgaatgga + xtcatcgaatggx + atcatcgaaxgga + atcaxxgaatgga + atcaxxgaatgxa + atcaxxgaatgg + """ + ) + expected = ([], [0, 12], [9], [4, 5], None, None) + + for r, exp in zip(results, expected): + if exp is not None: + self.assertEqual( + exp, + r[1].mismatches, + "fail CaselessCloseMatch between {!r} and {!r}".format( + searchseq.match_string, r[0] + ), + ) + print( + r[0], + "exc: %s" % r[1] + if exp is None and isinstance(r[1], Exception) + else ("no match", "match")[r[1].mismatches == exp], + ) + def testDefaultKeywordChars(self): with self.assertRaisesParseException( |