Callee provides a set of powerful argument matchers designed to extend the capabilities of Python's `unittest.mock` library. It allows developers to write more expressive and robust assertions for mocked calls, enabling checks for patterns, types, ranges, and more, beyond simple value equality. The current version is 0.3.1, with a stable but infrequent release cadence.
pip install calleeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `callee` matchers with `unittest.mock` to assert more complex argument patterns. It creates a mock object, calls a function that uses it, and then uses `Eq`, `Regex`, and `Any` matchers within `assert_has_calls` to verify the arguments passed to the mock.
Update your code to use `InstanceOf` instead of `class_of` and `call_args_are`/`call_kwargs_are` instead of their deprecated names.
Ensure `callee` matchers are passed as arguments to `unittest.mock` assertion methods, or used when inspecting `mock.call_args` through `callee.matchers.Matching(...)` if custom logic is required outside standard assertions.
Use `callee.Any` when you need to specify a type or apply additional conditions to 'any' argument. Use `unittest.mock.ANY` for a generic 'don't care' placeholder.
Ensure `callee` matchers are always passed as arguments to `unittest.mock` assertion methods, like `mock_obj.assert_called_with(Regex(r'some.*'))`.
Review the actual values being passed to the mock during the test run and compare them against the conditions defined by your `callee` matchers. Adjust either the test data or the matcher's expectation to align.
Add the necessary import statement at the top of your file: `from callee import Any` (or other specific matchers).
No dependency data recorded yet.