Post on 13-Apr-2017
HypothesisRandomised testing for DjangoRae Knowler, DjangoCon Europe 2015
Introduction
Rae Knowler
CKAN, Symfony, Django@RaeKnowlerthey/their/them
David MacIver and Sinister Katze
@DRMacIver @sinister_katze
Hypothesis
Property based testing libraryInspired by Haskell’s Quickcheck
http://hypothesis.readthedocs.org
Hypothesis
Why is it so great?
Why is it so great?
● Lots of randomised data
Why is it so great?
● Lots of randomised data● Simplifies examples
Why is it so great?
● Lots of randomised data● Simplifies examples● Remembers interesting inputs
Why is it so great?
● Lots of randomised data● Simplifies examples● Remembers interesting inputs● Can deal with complex data types
Why is it so great?
● Lots of randomised data● Simplifies examples● Remembers interesting inputs● Can deal with complex data types● Works with pytest and unittest
Hypothesis + Django
hypothesis-django
hypothesis-django
● Custom field types
hypothesis-django
● Custom field types● Generate child models
hypothesis-django
● Custom field types● Generate child models● Fixtures (new!)
Getting started
Install
pip install hypothesis
pip install hypothesis-django
Demo
Summary
Links
hypothesis.readthedocs.orggithub.com/bellisk/hypothesis-django-example
@RaeKnowlerraeknowler.com
Thank you!