| 738 | |
| 739 | |
| 740 | class PatternExpectation(Expectation): |
| 741 | def __init__(self, *circumstances): |
| 742 | self.circumstances = circumstances |
| 743 | |
| 744 | def test(self, first, last): |
| 745 | assert isinstance(first, Occurrence) |
| 746 | assert isinstance(last, Occurrence) |
| 747 | |
| 748 | for occ in first.and_following(up_to=last, inclusive=True): |
| 749 | if occ.circumstances == self.circumstances: |
| 750 | yield {self: occ} |
| 751 | |
| 752 | def describe(self): |
| 753 | rest = repr(self.circumstances[1:]) |
| 754 | if rest.endswith(",)"): |
| 755 | rest = rest[:-2] + ")" |
| 756 | return f"<{self.circumstances[0]}{rest}>" |
| 757 | |
| 758 | def __repr__(self): |
| 759 | return self.describe() |
| 760 | |
| 761 | |
| 762 | def Mark(id): |