
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
flexmock is a testing library for Python that makes it easy to create mocks, stubs and fakes.
flexmock - Mock, stub, and spy library for Python.
Flexmock is a testing library for Python that makes it easy to create mocks, stubs, and fakes.
Install with pip:
pip install flexmock
Flexmock features smooth integration with pretty much every popular test runner, so no special setup is necessary. Simply importing flexmock into your test module is sufficient to get started with any of the following examples:
from flexmock import flexmock
Assertions take many flavors and flexmock has many different facilities to generate them:
# Simplest is ensuring that a certain method is called
flexmock(Train).should_receive("get_tickets").once()
# Of course, it is also possible to provide a default return value
flexmock(Train).should_receive("get_destination").and_return("Paris").once()
# Or check that a method is called with specific arguments
flexmock(Train).should_receive("set_destination").with_args("Seoul").at_least().twice()
Instead of mocking, there are also times when you want to execute the actual method and simply find out how many times it was called. Flexmock uses should_call
to generate this sort of assertions instead of should_receive
:
# Verify that a method is called at most three times
flexmock(Train).should_call("get_tickets").at_most().times(3)
# Make sure that a method is never called with specific arguments
flexmock(Train).should_call("set_destination").with_args("Helsinki").never()
# More complex example with features like argument type and exception matching
flexmock(Train).should_call("crash").with_args(str, int).and_raise(AttributeError).once()
See more examples in the documentation.
User guide, examples, and a full API reference is available at: https://flexmock.readthedocs.io
Contributions are absolutely welcome and encouraged! See CONTRIBUTING.md to get started.
FAQs
flexmock is a testing library for Python that makes it easy to create mocks, stubs and fakes.
We found that flexmock demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.