Skip to content

chore(tests): replace __eq__() with diff() for detailed test diagnostics#314

Open
Molter73 wants to merge 1 commit intomainfrom
mauro/tests/diff-on-failure
Open

chore(tests): replace __eq__() with diff() for detailed test diagnostics#314
Molter73 wants to merge 1 commit intomainfrom
mauro/tests/diff-on-failure

Conversation

@Molter73
Copy link
Contributor

@Molter73 Molter73 commented Feb 19, 2026

Description

When test assertions fail, the error messages now show exactly which fields differ between expected and actual events, rather than just displaying raw protobuf dumps. This significantly improves debugging efficiency by pinpointing the specific mismatches in process attributes, event types, paths, and event-specific fields.

Assisted-by: Claude Sonnet 4.5 noreply@anthropic.com

Checklist

  • Investigated and inspected CI test results
  • Updated documentation accordingly

Automated testing

  • Added unit tests
  • Added integration tests
  • Added regression tests

If any of these don't apply, please comment below.

Testing Performed

Manually triggered an error in the test and got the following output:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <server.FileActivityService object at 0x7fedd0d99400>, events = [<event.Event object at 0x7fedd0c446e0>], strict = True

    def _wait_events(self, events: list[Event], strict: bool):
        while self.is_running():
            msg = self.get_next()
            if msg is None:
                sleep(0.5)
                continue

            print(f'Got event: {msg}')

            # Check if msg matches any expected event
            diff = events[0].diff(msg)
            if diff is None:
                events.pop(0)
                if len(events) == 0:
                    return
            elif strict:
>               raise ValueError(json.dumps(diff, indent=4))
E               ValueError: {
E                   "file": {
E                       "expected": "/home/mmoltras/worktrees/fact/diff-on-failure/tests/fact-test-z9wg7j8k/create.txtother",
E                       "actual": "/home/mmoltras/worktrees/fact/diff-on-failure/tests/fact-test-z9wg7j8k/create.txt"
E                   }
E               }

When test assertions fail, the error messages now show exactly which fields
differ between expected and actual events, rather than just displaying raw
protobuf dumps. This significantly improves debugging efficiency by pinpointing
the specific mismatches in process attributes, event types, paths, and
event-specific fields.

Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@Molter73 Molter73 marked this pull request as ready for review February 19, 2026 16:43
@Molter73 Molter73 requested a review from a team as a code owner February 19, 2026 16:43
@Molter73 Molter73 enabled auto-merge (squash) February 19, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments