PyConDE & PyData Berlin 2024

Bulletproof Python - Property-Based Testing with Hypothesis
04-23, 10:30–12:00 (Europe/Berlin), A05-A06

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 behaviour 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.

Please set up the workshop material in advance. To do that, navigate to the Git repository linked in the supporting material section and follow the setup instructions in the README file.


Expected audience expertise: Domain

Intermediate

Expected audience expertise: Python

Intermediate

Abstract as a tweet (X) or toot (Mastodon)

Less is more! Rather than working harder and write more test code, property-based testing forces you to work smarter and cover more cases with fewer tests. Join Michael for his Tutorial "Bulletproof Python - Property-Based Testing with Hypothesis"

Public link to supporting material, e.g. videos, Github, etc.

https://github.com/seifertm/hypothesis-workshop

Michael is a trainer and consulting software engineer who helps product teams develop Python software in the cloud. He enjoys deleting code more than writing it and is constantly looking for ways to make software easier to maintain.

Michael published his first FOSS project in 2006. He's the currently a maintainer of pytest-asyncio and happens to be a Shuffle Dance enthusiast.