Property-based testing the Python way
2022-07-13 , Liffey Hall 2

What if I told you you could write simpler tests but still get better results ?

What if I told you can automatically generate your test data ?

This may sound difficult to your traditional testing approach but can be easily done with property-based testing.

Property-based testing allows a range of inputs to be tested on a given aspect of a software property, abstracting away the details.

In the world of Python you can accomplish this with Hypothesis, the Python library used for property-based testing.

Hypothesis helps you design cleaner and clever test suites.


This is an introductory talk about property-based testing. The talk requires some previous knowledge about testing to make the most out of it but if you are new and curious I think you would get something out of it.

The talk approaches a simple problem from two different testing perspectives. Giving you an idea about property-based testing and how it’s different from the traditional approach with Python.

The main focus of the topic would be Hypothesis and how you can achieve your testing goals with it.

By the end of this talk you would have a solid understanding of property-based testing with Hypothesis, that would help you decide which testing approach fits your need.

Given below is a rough overview of the talk structure:

  • The testing problem - This is where you would explain the problem statement
  • The traditional approach
  • Cons of traditional approach
  • What is property-based testing ?
  • Intro to Hypothesis
  • Same problem solution with Hypothesis
  • Why choose Hypothesis as a go-to property based testing tool ?
  • Parametrized testing with Pytest vs Hypothesis approach
  • When or when not to use property based testing
  • How can you adopt hypothesis in your code base ? Some opinions here.

Expected audience expertise: Domain:

some

Expected audience expertise: Python:

some

Abstract as a tweet:

Design cleaner and clever test suites with Hypothesis, the Python library used for property-based testing.

Emma is a developer advocate at Alpaca. She enjoys sharing her knowledge and learning from fellow developers.