pyqcy

QuickCheck-like testing framework for Python
Download

pyqcy Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Karol Kuczmarski
  • Publisher web site:
  • http://github.com/Xion/

pyqcy Tags


pyqcy Description

pyqcy is a QuickCheck-like testing framework for Python.What, another testing utility?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 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!So, how does it look like?Try this:from pyqcy import qc, int_ main@qcdef addition_actually_works( x=int_(min=0), y=int_(min=0)): the_sum = x + y assert the_sum >= x and the_sum >= yif __name__ == '__main__': main()It will print:addition_actually_works: passed 100 tests.That's one hundred test cases generated automatically. In this example with int sit 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 using the @arbitrary decorator.See tests.py for more usage examples.How far does it go?Although quite functional (pun likely intended), the project is in experimental phase. The aim is to make it very similar to Haskell's QuickCheck, in extent permitted by the dynamic nature of Python.Ideas, suggestions and contributions are all very welcome.Product's homepage


pyqcy Related Software