A spy is a test double that wraps a real or fake object, records every call it receives, and lets the test inspect that record afterwards; it does not pre-commit to expectations, so it never fails on its own.
The distinction from a mock is subtle and it matters: a mock is pre-programmed with expectations ("this method must be called exactly once with these args"), and it fails the test if the contract is not honoured. A spy has no contract; it just logs what happened. The test inspects the log at the end and decides what to assert.
spy = Spy(real_repository)
service.create_user("ana@example.com")
assert spy.calls == [("save", ("ana@example.com",))]
Martin Fowler's 2007 taxonomy classifies spies as a kind of test double, alongside stubs, mocks, dummies and fakes [1]. Gerard Meszaros' xUnit Test Patterns describes them as "Test Spy" — a double that "captures indirect output" and makes it available for verification by the test itself [2].