argmatch

argmatch provides a wide collection of argument matchers to use with the standard unittest.mock library.

It allows you to write simple, readable, and powerful assertions on how the tested code should interact with your mocks:

from argmatch import Dict, StartsWith, String

mock_requests.get.assert_called_with(
    String() & StartsWith('https://'),
    params=Dict(String(), String()))

With argmatch, you can avoid both the overly lenient mock.ANY, as well as the tedious, error-prone code that manually checks Mock.call_args and call_args_list.

User’s Guide

Start here for the installation instructions and a quick, complete overview of argmatch and its usage.

API Reference

If you are looking for detailed information about all the matchers offered by argmatch, this is the place to go.