| 16 | |
| 17 | |
| 18 | class MatchResult: |
| 19 | |
| 20 | def __init__(self) -> None: |
| 21 | self.matches = True |
| 22 | self.match_count = 0 |
| 23 | self.unmatched_fields = {} |
| 24 | |
| 25 | def add_match(self): |
| 26 | self.match_count += 1 |
| 27 | |
| 28 | def add_miss(self, field_name, expected_value, actual_value): |
| 29 | self.matches = False |
| 30 | self.unmatched_fields[field_name] = (expected_value, actual_value) |
| 31 | |
| 32 | def add_match_result(self, field_name, expected_value, actual_value, custom_matcher=None): |
| 33 | if custom_matcher: |
| 34 | matches = custom_matcher() |
| 35 | else: |
| 36 | matches = expected_value == actual_value |
| 37 | |
| 38 | if matches: |
| 39 | self.add_match() |
| 40 | else: |
| 41 | self.add_miss(field_name, expected_value, actual_value) |
| 42 | |
| 43 | |
| 44 | class _MockHandler: |