Exercise 3: Fixing the Mock Drift Two Ways — Possible Solution ==================================================================== THE FIXES ------------------------------ (a) MockNotificationSenderFixed.send() accepts (email, subject, body) and expect_call() takes matching arguments. (b) UserRegistrationServiceFixed.register() now calls self.sender.send(email, "Welcome!", "Thanks for signing up!") - the new 3-argument call, matching what RealNotificationSenderV2 actually requires. RESULTS ------------------------------ Fixed mock-based test: expectation_met = True -> test PASSES Confirming it now genuinely matches the real dependency: Real dependency call: worked fine, no crash Both the mock-based test and a direct call against the real, previously-crashing RealNotificationSenderV2 now succeed, using the identical register() call in both cases. WHY THIS WORKS AS AN ANSWER ------------------------------ This closes the exact gap the chapter found: previously, the mock and the real dependency had silently drifted apart (the mock stuck on the old 2-argument signature while the real class and the code calling it moved to 3 arguments), and only the mock-based test's own result was ever checked day to day. Updating both the mock AND the calling code together - not just one or the other - restores the property a test double is supposed to guarantee: that passing against the double means the code would also work against the real thing. Fixing only the mock without fixing register() (or vice versa) would have left the same category of bug in place, just moved to a different mismatched pair.