Better Testing With Less Code (PyCon 2016 Must-See Talk: 2/6)

July 13, 2016

Part two of six in our annual PyCon Must-See Series, a weekly highlight of talks our staff especially loved at PyCon. With so many fantastic talks, it’s hard to know where to start, so here’s our short list.

I really enjoyed Matt Bachman’s talk, “Better Testing With Less Code: Property Based Testing With Python”. I heard about property-based testing from this great talk by Jessica Kerr (you should totally watch that talk too!). I'm not sure why, but I had assumed that this was only really doable in static-typed functional languages, so I was very interested to see Matt's talk to hear how this might be done in Python. He demonstrates using a library called Hypothesis to help specify "properties" of your code, and to then generate tests with random, valid input to assert that those properties hold. While this is an interesting approach to testing, I also think it's a valuable way to think about your code, which could help you write better programs. I really liked how Matt presented his topic. He encouraged listeners to start trying things out and sharing those trials so that we can all learn how to properly use this new approach.