Bulletproof Python – Property-Based Testing with Hypothesis
2022-09-21, 11:15–12:05 (Europe/Lisbon), Workshops

Property-based testing is a great benefit to the robustness and maintainability of your software. Yet, the technique is still vastly underused in the Python community. The workshop gives a hands-on introduction to Hypothesis and practices different approaches for writing property-based tests for Django applications.


Do you find yourself working through pages of copied and pasted tests to accommodate a simple code change? Does your software frequently break in unexpected ways despite your testing efforts? Don’t despair! Property-based testing could be your way out of that mess. Rather than working harder and writing more test code, property-based testing forces you to work smarter and test more code with fewer tests.

Traditional tests are example-based. They require the developer to come up with arbitrary inputs and check a system’s behavior against explicit outputs. More often than not, developers only think of inputs that are handled correctly by their code, thus leaving bugs hidden. Property-based tests generate the inputs for you and in many cases they’re more likely to find invalid inputs than humans. The difficulty lies in formulating these test cases.

After this workshop you’ll be comfortable with property-based testing using Hypothesis. You’ll have experience requesting appropriate test data from Hypothesis and in writing tests for common and more advanced properties. At work, your co-workers will be impressed by your unbreakable code ;)

Participants are expected to have basic familiarity with unit testing and a testing framework. Provided code examples use pytest.

Michael is a consulting software engineer who helps product teams to develop Python software in the cloud. He worked with many different teams from various industries, but none of them practised property-based testing and only few were familiar with the concept.

This prompted him to spread the word about property-based testing and Hypothesis in an effort to help others write more robust and maintainable software.