Skip to main content

argmatch

This project is a fork of callee.

Argument matchers for unittest.mock

Version Development Status Python Versions License Build Status

More robust tests

Python's mocking library (or its backport for Python <3.3) is simple, reliable, and easy to use. But it is also a little lacking when it comes to asserting what calls a mock has received.

You can be either very specific::

my_mock.assert_called_once_with(42, some_foo_object, 'certain string')

or extremely general::

my_mock.assert_called_with(ANY, ANY, ANY)
# passes as long as argument count is the same

| The former can make your tests over-specified, and thus fragile. | The latter could make them too broad, missing some erroneous cases and possibly letting your code fail in production.


argmatch provides argument matchers that allow you to be exactly as precise as you want::

my_mock.assert_called_with(GreaterThan(0), InstanceOf(Foo), String())

without tedious, handcrafted, and poorly readable code that checks call_args or call_args_list::

self.assertGreater(mock.call_args[0][0], 0)
self.assertIsInstance(mock.call_args[0][1], Foo)
self.assertIsInstance(mock.call_args[0][2], str)

It has plenty of matcher types to fit all common and uncommon needs, and you can easily write your own if necessary.

Installation


Installing *argmatch* is easy with pip::

    $ pip install argmatch

| *argmatch* support goes all the way back to Python 2.6.
| It also works both with the ``unittest.mock`` module from Python 3.3+ or its backport.


API reference

See the documentation_ for complete reference on the library usage and all available matchers.

.. _documentation: http://argmatch.readthedocs.org

Contributing


Contributions are welcome!
If you need ideas, head to the issue tracker or search for the various ``TODO``\ s scattered around the codebase.
Or just think what matchers you'd like to add :)

After cloning the repository, this should get you up and running::

    # ... create virtualenv as necessary ...
    pip install -r requirements-dev.txt
    tox

To regenerate documentation and display it in the browser, simply run::

    inv docs

Happy hacking!

Metadata

Release files for argmatch 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for argmatch 1.0.3
File Size Uploaded
argmatch-1.0.3.tar.gz 19.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for argmatch 1.0.3
File Interpreter ABI Platform
argmatch-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 44.2 kB

Release files / argmatch-1.0.3.tar.gz

Download URL argmatch-1.0.3.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a88d33df71fba22666aa458e353f4e8136303ebdbcd32e2c85a717e457e53f8d
BLAKE2b-256 checksum
How to use checksums
9037de31cef5a0962a9c3111a6e314483b45ef7f80b0f57774d24a7553fc20e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2025.

Transparency log

Release files / argmatch-1.0.3-py3-none-any.whl

Download URL argmatch-1.0.3-py3-none-any.whl
Size 24.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ee48f668076cd948dbac4f70140879dc45f0d423560992603462fef321ba5ae
BLAKE2b-256 checksum
How to use checksums
ddda70eca0f691ca4eaf91a79a7d66922a30a6d8532999fdac2506486a120366
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page