summaryrefslogtreecommitdiff
path: root/tests/integration_tests/log_utils.py
blob: 40baae7b79d2261c87e0f8e80a5fe275698dd8af (plain)
1
2
3
4
5
6
7
8
9
10
11
def verify_ordered_items_in_text(to_verify: list, text: str):
    """Assert all items in list appear in order in text.

    Examples:
      verify_ordered_items_in_text(['a', '1'], 'ab1')  # passes
      verify_ordered_items_in_text(['1', 'a'], 'ab1')  # raises AssertionError
    """
    index = 0
    for item in to_verify:
        index = text[index:].find(item)
        assert index > -1, "Expected item not found: '{}'".format(item)