Skip to main content

FlexMock provides a mock/stub/spy library for Python.

It is inspired by Ruby’s FlexMock, however full feature parity with the Ruby version is not a goal. Python FlexMock omits a number of things in the Ruby version, mainly various shortcuts for existing functionality, and implements a number of things that Ruby’s FlexMock doesn’t support, such as proxying/spying and matching arguments using their classes in addition to values.

What makes FlexMock unique in the Python testing world is its automatic integration with the test runner, allowing for really terse syntax and avoiding both the action->assertion and record->replay paradigms supported by all the other Python mocking libraries currently available. To be sure, you can still write your assertions in the action->assertion mode using FlexMock, but its powerful syntax allows you to define both the expectation and the assertion at the same time.

SUPPORTS:

  • test runner integration, i.e. automatic expectation checking on tearDown

  • advanced argument matching, including matching types and user-defined classes

  • expectations on number of times called, including at_least/at_most

  • mocks returning custom values, including different values on successive invokations

  • mocks raising custom exceptions

  • simple syntax for generating new mock objects

  • overriding new instances (on new-style objects)

  • parameter shortcuts for even terser syntax

  • proxying/spying using the and_execute expectation modifier

  • mocking a generator using and_yield

  • enforcing expectations ordering

Documentation:

https://github.com/has207/flexmock/wiki/Documentation

Changelog:

https://github.com/has207/flexmock/blob/master/CHANGELOG

Metadata

Release files for flexmock 0.6.6

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

Source distribution (sdist)

Source distribution for flexmock 0.6.6
File Size Uploaded Provenance Actions
flexmock-0.6.6.tar.gz 6.0 kB Without provenance Details for flexmock-0.6.6.tar.gz

Release files / flexmock-0.6.6.tar.gz

Download URL flexmock-0.6.6.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
65b86f3103a5882accffce2e65c528b4d5fddc88fdf5e1917766a94245c0e42d
BLAKE2b-256 checksum
How to use checksums
e928e75521a9980eabd8269969f87da33b306d3d552e134c5f654cee943e3ef7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for flexmock 0.6.6

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.6.6 This release

1 release file No provenance

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