No project description provided
Project description
argmatch
This project is a fork of callee.
Argument matchers for unittest.mock
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!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file argmatch-1.0.0.tar.gz.
File metadata
- Download URL: argmatch-1.0.0.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f6319913fbdee94ebefef5051b81ac0fc9e1eb4c9e0776f1a588b1bc753d8af
|
|
| MD5 |
09a68f0be15bfc8355d729b309584919
|
|
| BLAKE2b-256 |
527809979521df347913f559482f75f97caa64a67e20bef6794b43f2baf1eb2c
|
Provenance
The following attestation bundles were made for argmatch-1.0.0.tar.gz:
Publisher:
python-package.yml on mdgilene/argmatch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
argmatch-1.0.0.tar.gz -
Subject digest:
0f6319913fbdee94ebefef5051b81ac0fc9e1eb4c9e0776f1a588b1bc753d8af - Sigstore transparency entry: 449840472
- Sigstore integration time:
-
Permalink:
mdgilene/argmatch@a4acfd7ecd25340a376880320c7a558fbeba043c -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/mdgilene
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package.yml@a4acfd7ecd25340a376880320c7a558fbeba043c -
Trigger Event:
push
-
Statement type:
File details
Details for the file argmatch-1.0.0-py3-none-any.whl.
File metadata
- Download URL: argmatch-1.0.0-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44c61b7cc9cc497bf284e655e9434bc76f348f3eefca86949706f250c0f2442f
|
|
| MD5 |
55b7238b426b60bcaf55485361294948
|
|
| BLAKE2b-256 |
b55336a7736f96e579dcb1768f1df43eb1ea30eb1629fbe43db76e6a3743dc3b
|
Provenance
The following attestation bundles were made for argmatch-1.0.0-py3-none-any.whl:
Publisher:
python-package.yml on mdgilene/argmatch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
argmatch-1.0.0-py3-none-any.whl -
Subject digest:
44c61b7cc9cc497bf284e655e9434bc76f348f3eefca86949706f250c0f2442f - Sigstore transparency entry: 449840481
- Sigstore integration time:
-
Permalink:
mdgilene/argmatch@a4acfd7ecd25340a376880320c7a558fbeba043c -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/mdgilene
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package.yml@a4acfd7ecd25340a376880320c7a558fbeba043c -
Trigger Event:
push
-
Statement type: