sciwork 2023

Use Hypothesis, whether you like writing tests or not
2023-12-09, 10:15–10:45 (Asia/Taipei), NYCU

I bet you like writing tests. But instead of the example-based tests that we normally write, have you heard of property-based testing? By using Hypothesis, instead of thinking about what data I should test it for, it will generate test data, including Numpy and Pandas objects, for you.


Background:

Property-based testing is not well known in the Python community but it is a very powerful tool for testing codes thoroughly. In fact, CPython and other popular libraries like SciPy, Numpy and Pandas are using hypotheses. If we test by example, we can miss testing out on edge cases. With Hypothesis, someone can create tests that will automatically discover edge cases as long as the assumption of the condition of the input is correct. It will make writing tests much easier and better.

Goal:

With the introduction of Hypothesis and using it with scientific extras with testing best practices, audiences will be ready to perform property-based testing in their work. This will enhance the robustness of the tests and code that they write.

Target audiences:

Data scientists and researchers who use Python scientific libraries. No prior knowledge of property-based testing or Hypothesis is needed.

Outline:

  • Introduction to property-based testing, why is it useful
  • Introduction to Hypothesis and its scientific extra that works with Numpy and Pandas
  • Testing best practices using property-based testing
  • Showcase of examples
  • Summary, call to action, Q&A

Ask questions at slido


Prior Knowledge Expected?

No, previous knowledge expected

Language

English talk w. English slides

After having a career as a Data Scientist and Developer Advocate, Cheuk dedicated her work to the open-source community and working as a community manager at OpenSSF. She has co-founded Humble Data, a beginner Python workshop that has been happening around the world. She has served the EuroPython Society board for two years and is now a fellow and director of the Python Software Foundation.