view test/cmp_helper.py @ 7462:575002bb3f8a

Convert .note style to .news style on main page .note style's comment says it's for a news banner. So change .note to .news so it doesn't interfere with .. note:: directives used on the main page. AFAICT, this style isn't actually used anywhere.
author John Rouillard <rouilj@ieee.org>
date Wed, 07 Jun 2023 22:45:49 -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:], '')

Roundup Issue Tracker: http://roundup-tracker.org/