Socket
Socket
Sign inDemoInstall

mock_matchers

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock_matchers

hamcrest matchers for mock assertions


Maintainers
1

Readme

.. |pypi| image:: https://pypip.in/v/mock_matchers/badge.png :target: https://crate.io/packages/mock_matchers/ .. |license| image:: https://pypip.in/license/mock_matchers/badge.png :target: https://pypi.python.org/pypi/mock_matchers/ .. _PyHamcrest: https://pythonhosted.org/PyHamcrest/ .. _PyHamcrest Matchers: https://pythonhosted.org/PyHamcrest/library.html .. _mock: https://docs.python.org/3/library/unittest.mock.html


mock_matchers


|pypi| |license|

mock.matchers simply makes PyHamcrest_ matchers usable with the mock_ assertion calls.

Examples::

from mock import Mock 
import mock_matchers

m = Mock()
m.foo(1,2,3)
m.bar([1,2,3])

m.foo.assert_called_with(
    mock_matchers.instance_of(int),
    mock_matchers.instance_of(int),
    3
)
m.foo.assert_called_with(
    [
		mock_matchers.instance_of(int),
		2,
		3
    ]
)
m.foo.assert_called_with(mock_matchers.isntance_of(list))

etc... For a full list of available matchers refer to the PyHamcrest Matchers_ documentation and simply replace from hamcrest import <name_of_matcher> with from mock_matchers import <name_of_matcher>

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc