doublex started as a attempt to improve and simplify the codebase and API of the
pyDoubles framework (by Carlos Ble).
Respect to pyDoubles,
doublex has these features:
- Just hamcrest matchers (for all features).
- Only ProxySpy requires an instance. Other doubles accept a class too, but they never instantiate it.
- Properties may be stubbed and spied.
- Stub observers: Notify arbitrary hooks when methods are invoked. Useful to add “side effects”.
- Stub delegates: Use callables, iterables or generators to create stub return values.
- Mimic doubles: doubles that inherit the same collaborator subclasses. This provides full LSP for code that make strict type checking.
doublex solves all the issues and supports all the feature requests notified in the
pyDoubles issue tracker:
- assert keyword argument values
- assert that a method is called exactly one
- mocks impose invocation order
- doubles have framework public API
- stubs support keyword positional arguments
And some other features requested in the user group:
doublex provides the pyDoubles API as a wrapper for easy transition to doublex for
pyDoubles users. However, there are small differences. The bigger diference is that
pyDoubles matchers are not supported anymore, although you may get the same feature using
standard hamcrest matchers. Anyway, formally provided pyDoubles matchers are available as
doublex supports all the pyDoubles features and some more that can not be easily
backported. If you are a pyDoubles user you can run your tests using doublex.pyDoubles
module. However, we recommed the native doublex API for your new developments.
In most cases the only required change in your code is the
import sentence, that change from:
from doublex.pyDoubles import *
See the old pyDoubles documentation at http://pydoubles.readthedocs.org (that was formerly available in the pydoubles.org site).