Advanced Python Testing - mocking, property based testing, snapshot testing

In this walkthrough, take your Python testing skills to the next level. Tired of waiting for network requests, writing millions of edge cases and copy pasting outputs for testing? This walkthrough is for you. We will cover mocking external libraries and HTTP calls, property based testing, and using a snapshot testing library to make writing tests easier, faster and more fun! Mocking libraries allows us to test a code interface without requiring the underlying code to be run. This can be useful in testing databases and network requests without having to actually setup a database, or be connected to the Internet. Property based testing checks that a particular property is satisfied by the code. Rather than list specific instances of a property, property based testing frameworks allow you to describe the property and (possibly) find counterexamples. Snapshot based testing is useful for regression tests - to capture the output of a system at a particular state and ensure that it does not change. While snapshot based testing can be emulated using the standard Python library, it can be cumbersome to manually keep track of outputs. Snapshot testing libraries help with this. A recording of this session is available on YouTube: https://youtu.be/ozOEXz7G0p4

Institutions

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2024-12-06
DOI
https://doi.org/10.5281/zenodo.14290427
Primary Topic
Computational Physics and Python Applications
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Advanced Python Testing - mocking, property based testing, snapshot testing

Zenodo (CERN European Organization for Nuclear Research)
Computational Physics and Python Applications
article

Advanced Python Testing - mocking, property based testing, snapshot testing

article en

Abstract

In this walkthrough, take your Python testing skills to the next level. Tired of waiting for network requests, writing millions of edge cases and copy pasting outputs for testing? This walkthrough is for you. We will cover mocking external libraries and HTTP calls, property based testing, and using a snapshot testing library to make writing tests easier, faster and more fun! Mocking libraries allows us to test a code interface without requiring the underlying code to be run. This can be useful in testing databases and network requests without having to actually setup a database, or be connected to the Internet. Property based testing checks that a particular property is satisfied by the code. Rather than list specific instances of a property, property based testing frameworks allow you to describe the property and (possibly) find counterexamples. Snapshot based testing is useful for regression tests - to capture the output of a system at a particular state and ensure that it does not change. While snapshot based testing can be emulated using the standard Python library, it can be cumbersome to manually keep track of outputs. Snapshot testing libraries help with this. A recording of this session is available on YouTube: https://youtu.be/ozOEXz7G0p4

Zenodo (CERN European Organization for Nuclear Research)
Weatherford College (US)
Quality Education
Openalex Percentile: Top 61%
Computational Physics and Python Applications
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.