flexmock - Mock, stub, and spy library for Python.
Flexmock is a testing library for Python.
Its API is inspired by a Ruby library of the same name. However, it is not a goal of Python flexmock to be a clone of the Ruby version. Instead, the focus is on providing full support for testing Python programs and making the creation of fake objects as unobtrusive as possible.
As a result, Python flexmock removes a number of redundancies in the Ruby flexmock API, alters some defaults, and introduces several Python-only features.
Flexmock's design focuses on simplicity and intuitiveness. This means that the API is as lean as possible, though a few convenient short-hand methods are provided to aid brevity and readability.
Flexmock declarations are structured to read more like English sentences than API calls, and it is possible to chain them together in any order to achieve a high degree of expressiveness in a single line of code.
Install with pip:
pip install flexmock
Tested to work with:
- Python 3.6
- Python 3.7
- Python 3.8
- Python 3.9
- Python 3.10
Automatically integrates with all major test runners, including:
- twisted / trial