SlideShare ist ein Scribd-Unternehmen logo
1 von 7
5-minute intro to property-based testing in
Python with hypothesis
Franklin Chen
http://FranklinChen.com/
http://ConscientiousProgrammer.com/
Pittsburgh Python Meetup
June 26, 2013
Property-based testing vs. example-based testing
Example-based testing: assert that a property is true for some
values.
Are list appends associative?
Write some examples
def test_list_append_associative_example1():
x, y, z = [2], [3, 4, 5], [6, 7]
assert (x + y) + z == x + (y + z)
def test_list_append_associative_example2():
x, y, z = [2, 3], [], [6, 7]
assert (x + y) + z == x + (y + z)
# ...
Better: reduce boilerplate with parameters
pytest allows parameterization of arguments in tests.
Rewrite multiple examples as a single example
import pytest
@pytest.mark.parametrize (("x", "y", "z"), [
([2], [3, 4, 5], [6, 7]),
([2, 3], [], [6, 7])
])
def test_list_append_associative_parametrized(x, y, z):
assert (x + y) + z == x + (y + z)
Introduction to property-based hypothesis testing
from hypothesis.testdecorators import given
@given ([int], [int], [int])
def test_list_append_associative(x, y, z):
assert (x + y) + z == x + (y + z)
Passes!
hypothesis generates a “large” number of examples
Generation
Based on the type of the argument
Not exhaustive: failure to falsify does not mean true!
Default generators provided
You can write your own generators
A sample falsified hypothesis
@given (int, int)
def test_multiply_then_divide_is_same(x, y):
assert (x * y) / y == x
Result:
... falsifying_example = ((0, 0), {})
Some links
hypothesis documentation
pytest-quickcheck
My Pittsburgh Scala meetup talk on property-based testing
using ScalaCheck
Nat Pryce’s blog post on June 23, 2013
Conclusion
Property-based testing is a useful addition to your toolbox
Try it out in Python!
All materials for this talk available at https://github.com/
franklinchen/lightning-talk-on-hypothesis
Will write more about property-based testing on new blog
http://ConscientiousProgrammer.com/

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Generics
GenericsGenerics
Generics
 
Scala Collections : Java 8 on Steroids
Scala Collections : Java 8 on SteroidsScala Collections : Java 8 on Steroids
Scala Collections : Java 8 on Steroids
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Ti1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: PolymorphismTi1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: Polymorphism
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Java generics final
Java generics finalJava generics final
Java generics final
 
Collections Framework
Collections FrameworkCollections Framework
Collections Framework
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Scala Back to Basics: Type Classes
Scala Back to Basics: Type ClassesScala Back to Basics: Type Classes
Scala Back to Basics: Type Classes
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Unit Testing with Foq
Unit Testing with FoqUnit Testing with Foq
Unit Testing with Foq
 
Meet scala
Meet scalaMeet scala
Meet scala
 
Java Language fundamental
Java Language fundamentalJava Language fundamental
Java Language fundamental
 
Core java by a introduction sandesh sharma
Core java by a introduction sandesh sharmaCore java by a introduction sandesh sharma
Core java by a introduction sandesh sharma
 
Scala collections api expressivity and brevity upgrade from java
Scala collections api  expressivity and brevity upgrade from javaScala collections api  expressivity and brevity upgrade from java
Scala collections api expressivity and brevity upgrade from java
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
 
Scala for curious
Scala for curiousScala for curious
Scala for curious
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
 
SQL Server Select Topics
SQL Server Select TopicsSQL Server Select Topics
SQL Server Select Topics
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
 

Ähnlich wie 5-minute intro to property-based testing in Python with hypothesis

Hunting Bugs While Sleeping: Property-Based Testing with Continuous Integration
Hunting Bugs While Sleeping: Property-Based Testing with Continuous IntegrationHunting Bugs While Sleeping: Property-Based Testing with Continuous Integration
Hunting Bugs While Sleeping: Property-Based Testing with Continuous IntegrationPaul Lorett Amazona
 
Hunting Bugs While Sleeping: Property-Based Testing with C#
Hunting Bugs While Sleeping: Property-Based Testing with C#Hunting Bugs While Sleeping: Property-Based Testing with C#
Hunting Bugs While Sleeping: Property-Based Testing with C#Paul Lorett Amazona
 
unittest in 5 minutes
unittest in 5 minutesunittest in 5 minutes
unittest in 5 minutesRay Toal
 
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 AutumnGoptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 AutumnMasashi Shibata
 
Py.test
Py.testPy.test
Py.testsoasme
 
pytest로 파이썬 코드 테스트하기
pytest로 파이썬 코드 테스트하기pytest로 파이썬 코드 테스트하기
pytest로 파이썬 코드 테스트하기Yeongseon Choe
 
benpresentation_django
benpresentation_djangobenpresentation_django
benpresentation_djangoiiilx
 
java 8 Hands on Workshop
java 8 Hands on Workshopjava 8 Hands on Workshop
java 8 Hands on WorkshopJeanne Boyarsky
 
Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...
Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...
Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...PyData
 
What's new in Python 3.11
What's new in Python 3.11What's new in Python 3.11
What's new in Python 3.11Henry Schreiner
 
Effective testing with pytest
Effective testing with pytestEffective testing with pytest
Effective testing with pytestHector Canto
 
Using xUnit as a Swiss-Aarmy Testing Toolkit
Using xUnit as a Swiss-Aarmy Testing ToolkitUsing xUnit as a Swiss-Aarmy Testing Toolkit
Using xUnit as a Swiss-Aarmy Testing ToolkitChris Oldwood
 
Spock: Test Well and Prosper
Spock: Test Well and ProsperSpock: Test Well and Prosper
Spock: Test Well and ProsperKen Kousen
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPaulo Sergio Lemes Queiroz
 

Ähnlich wie 5-minute intro to property-based testing in Python with hypothesis (20)

Hunting Bugs While Sleeping: Property-Based Testing with Continuous Integration
Hunting Bugs While Sleeping: Property-Based Testing with Continuous IntegrationHunting Bugs While Sleeping: Property-Based Testing with Continuous Integration
Hunting Bugs While Sleeping: Property-Based Testing with Continuous Integration
 
Hunting Bugs While Sleeping: Property-Based Testing with C#
Hunting Bugs While Sleeping: Property-Based Testing with C#Hunting Bugs While Sleeping: Property-Based Testing with C#
Hunting Bugs While Sleeping: Property-Based Testing with C#
 
Auto testing!
Auto testing!Auto testing!
Auto testing!
 
Java Semantics
Java SemanticsJava Semantics
Java Semantics
 
unittest in 5 minutes
unittest in 5 minutesunittest in 5 minutes
unittest in 5 minutes
 
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 AutumnGoptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
 
Py.test
Py.testPy.test
Py.test
 
pytest로 파이썬 코드 테스트하기
pytest로 파이썬 코드 테스트하기pytest로 파이썬 코드 테스트하기
pytest로 파이썬 코드 테스트하기
 
Dynamic Python
Dynamic PythonDynamic Python
Dynamic Python
 
benpresentation_django
benpresentation_djangobenpresentation_django
benpresentation_django
 
java 8 Hands on Workshop
java 8 Hands on Workshopjava 8 Hands on Workshop
java 8 Hands on Workshop
 
Ds lab handouts
Ds lab handoutsDs lab handouts
Ds lab handouts
 
Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...
Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...
Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...
 
Begin with Python
Begin with PythonBegin with Python
Begin with Python
 
What's new in Python 3.11
What's new in Python 3.11What's new in Python 3.11
What's new in Python 3.11
 
Effective testing with pytest
Effective testing with pytestEffective testing with pytest
Effective testing with pytest
 
Using xUnit as a Swiss-Aarmy Testing Toolkit
Using xUnit as a Swiss-Aarmy Testing ToolkitUsing xUnit as a Swiss-Aarmy Testing Toolkit
Using xUnit as a Swiss-Aarmy Testing Toolkit
 
Spock: Test Well and Prosper
Spock: Test Well and ProsperSpock: Test Well and Prosper
Spock: Test Well and Prosper
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPU
 
Python basic
Python basicPython basic
Python basic
 

Kürzlich hochgeladen

Hire 💕 8617697112 Surat Call Girls Service Call Girls Agency
Hire 💕 8617697112 Surat Call Girls Service Call Girls AgencyHire 💕 8617697112 Surat Call Girls Service Call Girls Agency
Hire 💕 8617697112 Surat Call Girls Service Call Girls AgencyNitya salvi
 
Visa Consultant in Lahore || 📞03094429236
Visa Consultant in Lahore || 📞03094429236Visa Consultant in Lahore || 📞03094429236
Visa Consultant in Lahore || 📞03094429236Sherazi Tours
 
Genuine 9332606886 Hot and Beautiful 💕 Pune Escorts call Girls
Genuine 9332606886 Hot and Beautiful 💕 Pune Escorts call GirlsGenuine 9332606886 Hot and Beautiful 💕 Pune Escorts call Girls
Genuine 9332606886 Hot and Beautiful 💕 Pune Escorts call GirlsDeiva Sain Call Girl
 
Varanasi Call Girls 8250077686 Service Offer VIP Hot Model
Varanasi Call Girls 8250077686 Service Offer VIP Hot ModelVaranasi Call Girls 8250077686 Service Offer VIP Hot Model
Varanasi Call Girls 8250077686 Service Offer VIP Hot ModelDeiva Sain Call Girl
 
Kanpur Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Kanpur Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceKanpur Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Kanpur Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceDamini Dixit
 
Genuine 8250077686 Hot and Beautiful 💕 Hosur Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Hosur Escorts call GirlsGenuine 8250077686 Hot and Beautiful 💕 Hosur Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Hosur Escorts call GirlsDeiva Sain Call Girl
 
Genuine 8250077686 Hot and Beautiful 💕 Amaravati Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Amaravati Escorts call GirlsGenuine 8250077686 Hot and Beautiful 💕 Amaravati Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Amaravati Escorts call GirlsDeiva Sain Call Girl
 
sample sample sample sample sample sample
sample sample sample sample sample samplesample sample sample sample sample sample
sample sample sample sample sample sampleCasey Keith
 
Genuine 9332606886 Hot and Beautiful 💕 Bilaspur Escorts call Girls
Genuine 9332606886 Hot and Beautiful 💕 Bilaspur Escorts call GirlsGenuine 9332606886 Hot and Beautiful 💕 Bilaspur Escorts call Girls
Genuine 9332606886 Hot and Beautiful 💕 Bilaspur Escorts call GirlsDeiva Sain Call Girl
 
sample sample sample sample sample sample
sample sample sample sample sample samplesample sample sample sample sample sample
sample sample sample sample sample sampleCasey Keith
 
2k Shots ≽ 9205541914 ≼ Call Girls In Tagore Garden (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Tagore Garden (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Tagore Garden (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Tagore Garden (Delhi)Delhi Call girls
 
Genesis 1:6 || Meditate the Scripture daily verse by verse
Genesis 1:6  ||  Meditate the Scripture daily verse by verseGenesis 1:6  ||  Meditate the Scripture daily verse by verse
Genesis 1:6 || Meditate the Scripture daily verse by versemaricelcanoynuay
 
WhatsApp Chat: 📞 8617697112 Hire Call Girls Cooch Behar For a Sensual Sex Exp...
WhatsApp Chat: 📞 8617697112 Hire Call Girls Cooch Behar For a Sensual Sex Exp...WhatsApp Chat: 📞 8617697112 Hire Call Girls Cooch Behar For a Sensual Sex Exp...
WhatsApp Chat: 📞 8617697112 Hire Call Girls Cooch Behar For a Sensual Sex Exp...Nitya salvi
 
Hire 💕 8617697112 Reckong Peo Call Girls Service Call Girls Agency
Hire 💕 8617697112 Reckong Peo Call Girls Service Call Girls AgencyHire 💕 8617697112 Reckong Peo Call Girls Service Call Girls Agency
Hire 💕 8617697112 Reckong Peo Call Girls Service Call Girls AgencyNitya salvi
 
Hire 💕 8617697112 Champawat Call Girls Service Call Girls Agency
Hire 💕 8617697112 Champawat Call Girls Service Call Girls AgencyHire 💕 8617697112 Champawat Call Girls Service Call Girls Agency
Hire 💕 8617697112 Champawat Call Girls Service Call Girls AgencyNitya salvi
 
Ooty Call Girls 8250077686 Service Offer VIP Hot Model
Ooty Call Girls 8250077686 Service Offer VIP Hot ModelOoty Call Girls 8250077686 Service Offer VIP Hot Model
Ooty Call Girls 8250077686 Service Offer VIP Hot ModelDeiva Sain Call Girl
 
🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...
🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...
🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...Apsara Of India
 
Genuine 8250077686 Hot and Beautiful 💕 Visakhapatnam Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Visakhapatnam Escorts call GirlsGenuine 8250077686 Hot and Beautiful 💕 Visakhapatnam Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Visakhapatnam Escorts call GirlsDeiva Sain Call Girl
 
Sample sample sample sample sample sample
Sample sample sample sample sample sampleSample sample sample sample sample sample
Sample sample sample sample sample sampleCasey Keith
 

Kürzlich hochgeladen (20)

Hire 💕 8617697112 Surat Call Girls Service Call Girls Agency
Hire 💕 8617697112 Surat Call Girls Service Call Girls AgencyHire 💕 8617697112 Surat Call Girls Service Call Girls Agency
Hire 💕 8617697112 Surat Call Girls Service Call Girls Agency
 
Visa Consultant in Lahore || 📞03094429236
Visa Consultant in Lahore || 📞03094429236Visa Consultant in Lahore || 📞03094429236
Visa Consultant in Lahore || 📞03094429236
 
Genuine 9332606886 Hot and Beautiful 💕 Pune Escorts call Girls
Genuine 9332606886 Hot and Beautiful 💕 Pune Escorts call GirlsGenuine 9332606886 Hot and Beautiful 💕 Pune Escorts call Girls
Genuine 9332606886 Hot and Beautiful 💕 Pune Escorts call Girls
 
Varanasi Call Girls 8250077686 Service Offer VIP Hot Model
Varanasi Call Girls 8250077686 Service Offer VIP Hot ModelVaranasi Call Girls 8250077686 Service Offer VIP Hot Model
Varanasi Call Girls 8250077686 Service Offer VIP Hot Model
 
Kanpur Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Kanpur Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceKanpur Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Kanpur Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
 
Genuine 8250077686 Hot and Beautiful 💕 Hosur Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Hosur Escorts call GirlsGenuine 8250077686 Hot and Beautiful 💕 Hosur Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Hosur Escorts call Girls
 
Genuine 8250077686 Hot and Beautiful 💕 Amaravati Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Amaravati Escorts call GirlsGenuine 8250077686 Hot and Beautiful 💕 Amaravati Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Amaravati Escorts call Girls
 
sample sample sample sample sample sample
sample sample sample sample sample samplesample sample sample sample sample sample
sample sample sample sample sample sample
 
Genuine 9332606886 Hot and Beautiful 💕 Bilaspur Escorts call Girls
Genuine 9332606886 Hot and Beautiful 💕 Bilaspur Escorts call GirlsGenuine 9332606886 Hot and Beautiful 💕 Bilaspur Escorts call Girls
Genuine 9332606886 Hot and Beautiful 💕 Bilaspur Escorts call Girls
 
sample sample sample sample sample sample
sample sample sample sample sample samplesample sample sample sample sample sample
sample sample sample sample sample sample
 
2k Shots ≽ 9205541914 ≼ Call Girls In Tagore Garden (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Tagore Garden (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Tagore Garden (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Tagore Garden (Delhi)
 
Genesis 1:6 || Meditate the Scripture daily verse by verse
Genesis 1:6  ||  Meditate the Scripture daily verse by verseGenesis 1:6  ||  Meditate the Scripture daily verse by verse
Genesis 1:6 || Meditate the Scripture daily verse by verse
 
WhatsApp Chat: 📞 8617697112 Hire Call Girls Cooch Behar For a Sensual Sex Exp...
WhatsApp Chat: 📞 8617697112 Hire Call Girls Cooch Behar For a Sensual Sex Exp...WhatsApp Chat: 📞 8617697112 Hire Call Girls Cooch Behar For a Sensual Sex Exp...
WhatsApp Chat: 📞 8617697112 Hire Call Girls Cooch Behar For a Sensual Sex Exp...
 
CYTOTEC DUBAI ☎️ +966572737505 } Abortion pills in Abu dhabi,get misoprostal ...
CYTOTEC DUBAI ☎️ +966572737505 } Abortion pills in Abu dhabi,get misoprostal ...CYTOTEC DUBAI ☎️ +966572737505 } Abortion pills in Abu dhabi,get misoprostal ...
CYTOTEC DUBAI ☎️ +966572737505 } Abortion pills in Abu dhabi,get misoprostal ...
 
Hire 💕 8617697112 Reckong Peo Call Girls Service Call Girls Agency
Hire 💕 8617697112 Reckong Peo Call Girls Service Call Girls AgencyHire 💕 8617697112 Reckong Peo Call Girls Service Call Girls Agency
Hire 💕 8617697112 Reckong Peo Call Girls Service Call Girls Agency
 
Hire 💕 8617697112 Champawat Call Girls Service Call Girls Agency
Hire 💕 8617697112 Champawat Call Girls Service Call Girls AgencyHire 💕 8617697112 Champawat Call Girls Service Call Girls Agency
Hire 💕 8617697112 Champawat Call Girls Service Call Girls Agency
 
Ooty Call Girls 8250077686 Service Offer VIP Hot Model
Ooty Call Girls 8250077686 Service Offer VIP Hot ModelOoty Call Girls 8250077686 Service Offer VIP Hot Model
Ooty Call Girls 8250077686 Service Offer VIP Hot Model
 
🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...
🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...
🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...
 
Genuine 8250077686 Hot and Beautiful 💕 Visakhapatnam Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Visakhapatnam Escorts call GirlsGenuine 8250077686 Hot and Beautiful 💕 Visakhapatnam Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Visakhapatnam Escorts call Girls
 
Sample sample sample sample sample sample
Sample sample sample sample sample sampleSample sample sample sample sample sample
Sample sample sample sample sample sample
 

5-minute intro to property-based testing in Python with hypothesis

  • 1. 5-minute intro to property-based testing in Python with hypothesis Franklin Chen http://FranklinChen.com/ http://ConscientiousProgrammer.com/ Pittsburgh Python Meetup June 26, 2013
  • 2. Property-based testing vs. example-based testing Example-based testing: assert that a property is true for some values. Are list appends associative? Write some examples def test_list_append_associative_example1(): x, y, z = [2], [3, 4, 5], [6, 7] assert (x + y) + z == x + (y + z) def test_list_append_associative_example2(): x, y, z = [2, 3], [], [6, 7] assert (x + y) + z == x + (y + z) # ...
  • 3. Better: reduce boilerplate with parameters pytest allows parameterization of arguments in tests. Rewrite multiple examples as a single example import pytest @pytest.mark.parametrize (("x", "y", "z"), [ ([2], [3, 4, 5], [6, 7]), ([2, 3], [], [6, 7]) ]) def test_list_append_associative_parametrized(x, y, z): assert (x + y) + z == x + (y + z)
  • 4. Introduction to property-based hypothesis testing from hypothesis.testdecorators import given @given ([int], [int], [int]) def test_list_append_associative(x, y, z): assert (x + y) + z == x + (y + z) Passes! hypothesis generates a “large” number of examples Generation Based on the type of the argument Not exhaustive: failure to falsify does not mean true! Default generators provided You can write your own generators
  • 5. A sample falsified hypothesis @given (int, int) def test_multiply_then_divide_is_same(x, y): assert (x * y) / y == x Result: ... falsifying_example = ((0, 0), {})
  • 6. Some links hypothesis documentation pytest-quickcheck My Pittsburgh Scala meetup talk on property-based testing using ScalaCheck Nat Pryce’s blog post on June 23, 2013
  • 7. Conclusion Property-based testing is a useful addition to your toolbox Try it out in Python! All materials for this talk available at https://github.com/ franklinchen/lightning-talk-on-hypothesis Will write more about property-based testing on new blog http://ConscientiousProgrammer.com/