Mercurial > p > roundup > code
view test/cmp_helper.py @ 5920:ff7e089fd4ef
support python 3.4 testing
python 3.4 is not supported by any 1.4 release of mysqlclient. Pip is
installing the 1.4.4 version even when run from python 3.4. Check
version and install 1.3.14 on python 3.4 but newest one on all other
versions.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 13 Oct 2019 14:17:33 -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:], '')
