QuickCheck-like testing framework for Python
It's true that Python has plethora of testing tools, especially when it comes to unit tests. So why would anyone want another library dedicated to this end?...
For one, pyqcy [pyksi:] supports a unique testing model, inspired by the brilliant QuickCheck library for Haskell. Rather than writing fully-fledged test cases, you only need to define logical properties that your code has to satisfy. Based on that, pyqcy will automatically generate test cases - hundreds of them, in fact!
$ pip install pyqcy
and then try this:
from pyqcy import qc, int_, main @qc def addition_actually_works( x=int_(min=0), y=int_(min=0) ): the_sum = x + y assert the_sum >= x and the_sum >= y if __name__ == '__main__': main()
It will print:
$ python ./example.py addition_actually_works: passed 100 tests.
That's one hundred test cases generated automatically. In this example
ints it is of course very simple, but pyqcy already
has support for most Python types, including strings and lists.
Futhermore it also allows you to define your own generators
Check out the docs for comprehensive explanation of features currently offered by pyqcy.
The aim of this project is to make it very similar to Haskell's QuickCheck, in extent permitted by the dynamic nature of Python. So far it turned out to be quite big extent :)
Sure thing! Ideas, suggestions and of course contributions are all very welcome.
If you want to start hacking at pyqcy right away, just clone it from here and install in development mode (preferably inside a virtualenv):
$ git clone git://github.com/Xion/pyqcy.git $ cd pyqcy $ python ./setup.py develop
Then you should be able to run tests through nose:
$ pip install nose mocktest $ nosetests