PyCon DE & PyData 2025

Supercharge Your Testing with inline-snapshot
2025-04-23 , Ferrum

Snapshot tests are invaluable when you are working with large, complex, or frequently changing expected values in your tests.
Introducing inline-snapshot, a Python library designed for snapshot testing that integrates seamlessly with pytest, allowing you to embed snapshot values directly within your source code.
This approach not only simplifies test management but also boosts productivity by improving the maintenance of the tests.
It is particularly useful for integration testing and can be used to write your own abstractions to test complex Apis.


This Talk gives you an introduction into inline-snapshot and how it can transform your testing strategy:
* Foundations of Snapshot Testing: Start with an introduction to what snapshot testing is and why it's a game-changer for Python developers.
* Basic Usage: Learn the core functionality of the snapshot() function. Understand how it captures and manages snapshots inline with your tests.

Advanced Techniques:
* Dirty Equals: Explore how you can leverage dirty-equals within your snapshots for more flexible assertions, allowing for partial matching which is particularly useful for complex data structures.
* Parametrized Tests: See how inline-snapshot can be applied to parametrized tests, ensuring each parameter set has its own snapshot.
* Customizable: Learn to create your own test functions to test your specific problems.


Expected audience expertise: Domain:

Intermediate

Expected audience expertise: Python:

Intermediate

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

https://github.com/15r10nk/inline-snapshot

I'm a software developer. My goal with my opensource work is to help other people to develop better software faster.