PyBehave

PyBehave is a simplified implementation of jBehave. It allows the writing of stories and scenarios using the given/when/ensure pattern. It also provides the generation of stories from their textual specification.

PyBehave has been used with pymock, but should be usable with other mock framework. For the moment, raw python assert are used for expressing tests’ success and failures.

Implementation

It is provided as a python package using setuptools and as an Egg for Python 2.5. To install PyBehave as a package, use the setup.py script.


pybehave-x.y.z $ python setup.py build
pybehave-x.y.z $ sudo python setup.py install

To install PyBehave as an Egg, use easy_install.


$ easy_install pybehave-x.y.z-py2.5.egg

The packages installation contains an examples folder that contains a textual specification as well as its translation to tests and their implementation.

In both case, modules are commented and tested using doctest.


examples $ ls
atm.story
examples $ spec2behave --skel atm.story
examples $ ls
atm.story                       user_withdraws_cash_skels.py
user_withdraws_cash.py
# edit user_withdraws_cash_skels.py to write your tests
# implement the atm module 
examples $ python user_withdraws_cash.py 
* User withdraws cash
  - Happy scenario: SUCCESS
  - Happy scenario with overdraft: SUCCESS
  - Overdrawn without permission: SUCCESS
  - In lots of trouble: SUCCESS
examples $

Dowmload

PyBehave 0.1.5 source archive

PyBehave 0.1.5 Egg