Skip to main content

Mock/Stub/Spy library for Python inspired by Ruby's FlexMock

Project description

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, returning different arguments on successive method calls, 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

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

flexmock-0.6.5.tar.gz (6.2 kB view details)

Uploaded Source

File details

Details for the file flexmock-0.6.5.tar.gz.

File metadata

  • Download URL: flexmock-0.6.5.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for flexmock-0.6.5.tar.gz
Algorithm Hash digest
SHA256 b4177a8abf3ea1dd974097107d7f28d0909ddcd3243b456e0559d24126cc3dd3
MD5 c6f94badc112eee99978529e8e1bfa2d
BLAKE2b-256 25f301091f9cbb49268b8059cb3e15fdbe1e0e7a26bb4334761f472eae92d9a9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page