Nov 23, 2026
|
56 min
|
774 views
How do you do basic testing in Python? (pytest and makefiles) | Rich Iannone | Data Science Lab
You can use straightforward assert statements, alias routine terminal workflows with a Makefile, and use @pytest.mark.parametrize to test multiple edge cases at once! And you don’t have to be perfect or overwhelmed.
The Data Science Lab is a live weekly call. Register at pos.it/dslab! Discord invites go out each week on lives calls. We’d love to have you! It’s is an open, messy space for learning and asking questions. Think of it like pair coding with a friend or two. Learn something new, and share what you know to help others grow.
On this Lab, Rich Iannone, Software Engineer at Post PBC, walks through some beginner concepts using a really small example python package (tinytab) as a reference. He talks about using a makefile so he doesn’t have to remember how to type complicated terminal commands, how he sets up files/folders, and all about assert statements. It’s a laid-back time and we hope you get a little more comfy in python and testing while hanging with us!
Hosting crew from Posit: Libby Heeren, Isabella Velasquez Recorded: October 13, 2026
Rich Iannone’s socials and urls: Bluesky: https://bsky.app/profile/richmeister.bsky.social LinkedIn: ttps://www.linkedin.com/in/richard-iannone-a5640017/ GitHub: https://github.com/rich-iannone
Resources: pytest history: https://docs.pytest.org/en/stable/history.html Rich’s testing resources (his example tinytab repo he’s using on-screen): https://rich-iannone.github.io/example-python-package/packaging/testing.html pyOpenSci Python package guide: https://www.pyopensci.org/python-package-guide/ Python Packages testing chapter (textbook): https://py-pkgs.org/05-testing syrupy library: https://pypi.org/project/syrupy pytest-snapshot: https://pypi.org/project/pytest-snapshot/ conftest.py in Rich’s example package: https://github.com/rich-iannone/example-python-package/blob/main/tests/conftest.py Skipping tests and xfail in pytest: https://docs.pytest.org/en/stable/how-to/skipping.html Playwright: https://playwright.dev/ TSLgenerator manual: https://github.com/alexorso/tslgenerator/blob/master/Docs/TSLgenerator-manual.txt Sublime Text: https://www.sublimetext.com/ What’s in a name? (explaining src/ layout): https://github.com/chendaniely/whatsinaname VS Code vertical rulers: https://dev.to/brad_beggs/vs-code-vertical-rulers-for-prettier-code-3gp3 Just Programmer’s Manual: https://just.systems/man/en/ testthat expectations reference: https://testthat.r-lib.org/reference/index.html#expectations GNU Make manual: https://www.gnu.org/software/make/manual/make.html The case for Makefiles in Python projects (KDnuggets): https://www.kdnuggets.com/the-case-for-makefiles-in-python-projects-and-how-to-get-started Quarto: https://quarto.org/ Great Docs: https://posit-dev.github.io/great-docs/ Rich’s example Python package: https://github.com/rich-iannone/example-python-package
Timestamps: 00:00 Introduction 01:45 Example Python package overview (TinyTab) 05:08 Using Makefiles and make test to run tests 07:24 What is a test? Basic PyTest functions and assert statements 10:37 “Have you ever used an assert statement in Python?” 11:42 Debugging failed assertions in PyTest 13:57 Parametrizing tests with @pytest.mark.parametrize 16:24 “When you run make test, does it run the entire test file?” 16:50 “When you run individual tests, do you use Command+Enter?” 18:47 Adding custom IDs to parametrized tests 20:53 “What keyboard shortcuts do you use to highlight a row and reorder it?” 22:45 Python package structure conventions (src/ layout vs. root) 25:25 Testing edge cases, formatted output, and negative values 30:16 “Do you do formal testing where you try to break your code in every way you can?” 32:45 Testing error handling and exceptions with pytest.raises 34:15 “What if we want to skip a test?” (Using skip and xfail) 38:03 “What is the conftest file you mentioned earlier?” 40:25 “Is that a helper object for building tests, or is it part of your package?” 43:28 Snapshot testing with Syrupy 46:49 Updating snapshots with make test-update 49:17 “What is test coverage?” 51:17 “Are there situations where a Jupyter Notebook should be used instead of Quarto?” 52:48 “Is there a particular functionality in PyTest that makes it preferable to other libraries like unittest, or is it just preference and familiarity for Rich?” 54:25 pytest recap and testing best practices
Great Docs
Quarto
testthat