Mercurial > p > roundup > code
view test/cmp_helper.py @ 7859:9a74dfeb8620
feat: can use escaped tokens inside quotes including quotes.
Change tokenizer to support:
cmd with arg "string with embedded \" double quote"
works for single quotes too. Mixed quotes can skip the \" or \'
escaping.
Also:
quoted cmds args "can include \n newline, \t tab and \r return"
Added a doc example, also tests for new feature.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 06 Apr 2024 20:37:45 -0400 |
| parents | 19bd4b413ed6 |
| children |
line wrap: on
line source
class StringFragmentCmpHelper: def compareStringFragments(self, s, fragments): """Compare a string agains a list of fragments where a tuple denotes a set of alternatives """ pos = 0 for frag in fragments: if type(frag) != tuple: self.assertEqual(s[pos:pos + len(frag)], frag) pos += len(frag) else: found = False for alt in frag: if s[pos:pos + len(alt)] == alt: pos += len(alt) found = True break if not found: l = max(map(len, frag)) raise AssertionError('%s != %s' % (repr(s[pos:pos + l]), str(frag))) self.assertEqual(s[pos:], '')
