PLAY PODCASTS
Eric Matthes: Maybe Don't Start With Unit Tests
Episode 242

Eric Matthes: Maybe Don't Start With Unit Tests

The Real Python Podcast · Real Python

March 7, 20251h 10m

Audio is streamed directly from the publisher (dts.podtrac.com) as published in their RSS feed. Play Podcasts does not host this file. Rights-holders can request removal through the copyright & takedown page.

Show Notes

<p>Should you always start testing your code with unit tests? When does it make sense to look at integration or end-to-end testing as a first step instead? This week on the show, we speak with previous guest Eric Matthes about where to begin testing your code.</p> <p>Eric is the author of the popular book <em>Python Crash Course</em>. Early in the development of the book, he decided to introduce testing and added a chapter on testing code with pytest.</p> <p>Over the past couple of years, Eric has continued to consider when and where to test a project&rsquo;s code. He thinks there are hazards to always starting with unit tests. The type of project and its audience should determine what kind of testing to employ initially.</p> <p>We discuss using pytest to develop integration tests on multiple types of projects. We also explore fixtures and what goes into building a test suite. Eric also shares criteria for when and where it makes sense to add unit tests to a project.</p> <div class="alert alert-primary" role="alert"> <p><strong>Course Spotlight:</strong> <a href="https://realpython.com/courses/python-assert-statement/">Using Python&rsquo;s assert to Debug and Test Your Code</a></p> <p>In this course, you&rsquo;ll learn how to use Python&rsquo;s assert statement to document, debug, and test code in development. You&rsquo;ll learn how assertions might be disabled in production code, so you shouldn&rsquo;t use them to validate data. You&rsquo;ll also learn about a few common pitfalls of assertions in Python.</p> </div> <p>Topics:</p> <ul> <li>00:00:00 &ndash; Introduction</li> <li>00:01:47 &ndash; Submitting talks to conferences</li> <li>00:04:10 &ndash; Don&rsquo;t start with unit tests!</li> <li>00:07:35 &ndash; How did you start with testing?</li> <li>00:11:30 &ndash; Example of a project needing tests</li> <li>00:14:54 &ndash; Defining types of tests</li> <li>00:16:44 &ndash; Integration vs end-to-end tests</li> <li>00:19:09 &ndash; When should you build tests?</li> <li>00:22:13 &ndash; Trade offs of integration vs unit tests</li> <li>00:24:05 &ndash; Why is there push back on this idea?</li> <li>00:27:36 &ndash; Video Course Spotlight</li> <li>00:29:09 &ndash; Using pytest</li> <li>00:33:24 &ndash; Transcripts project example</li> <li>00:37:03 &ndash; py-image-border project</li> <li>00:40:29 &ndash; Criteria for when you should write unit tests</li> <li>00:48:51 &ndash; How to practice writing tests</li> <li>00:50:28 &ndash; Building an integration test and pytest fixtures</li> <li>00:55:05 &ndash; What&rsquo;s in the test folder?</li> <li>00:56:31 &ndash; Idea for a PyCon tutorial on implementing tests</li> <li>00:57:29 &ndash; Other pytest advice and parametrization</li> <li>01:01:13 &ndash; Caveats to not starting with unit tests</li> <li>01:02:30 &ndash; pytest documentation and other advice</li> <li>01:05:23 &ndash; How to reach Eric online</li> <li>01:06:47 &ndash; What are you excited about in the world of Python?</li> <li>01:08:23 &ndash; What do you want to learn next?</li> <li>01:09:48 &ndash; What conferences are you attending?</li> <li>01:10:06 &ndash; Thanks and goodbye</li> </ul> <p>Show Links:</p> <ul> <li><a href="https://www.mostlypython.com/dont-start-with-unit-tests/">Don&rsquo;t start with unit tests - by Eric Matthes</a></li> <li><a href="https://www.youtube.com/watch?v=yEemdaHqL0E">Sleep Better By Writing Python Tests with Eric Matthes - YouTube</a></li> <li><a href="https://realpython.com/podcasts/rpp/163/">Episode #163: Python Crash Course &amp; Learning Enough to Start Creating</a></li> <li><a href="https://github.com/initialcommit-com/git-sim">git-sim: Visually simulate Git operations in your own repos with a single terminal command</a></li> <li><a href="https://www.manim.community/">Manim Community</a></li> <li><a href="https://django-simple-deploy.readthedocs.io/en/latest/">django-simple-deploy</a></li> <li><a href="https://learngrandstaff.com/index.html">Learn the grand staff!</a></li> <li><a href="https://github.com/ehmatthes/py-image-border">py-image-border: Add a border to any image</a></li> <li><a href="https://docs.pytest.org/en/stable/getting-started.html">pytest Documentation - Get Started</a></li> <li><a href="https://docs.pytest.org/en/stable/explanation/fixtures.html#about-fixtures">About fixtures - pytest documentation</a></li> <li><a href="https://docs.pytest.org/en/stable/example/parametrize.html">Parametrizing tests - pytest documentation</a></li> <li><a href="https://astral.sh/blog/uv-unified-python-packaging">uv: Unified Python packaging</a></li> <li><a href="https://sequential.com/product/take-5-compact-poly-synth/">Prophet 5 Compact Poly Synth - Sequential</a></li> <li><a href="https://us.pycon.org/2025/">PyCon US 2025</a></li> <li><a href="https://ep2025.europython.eu/">EuroPython 2025 - July 14th-20th 2025 - Prague, Czech Republic &amp; Remote</a></li> <li><a href="https://nostarch.com/python-crash-course-3rd-edition">Python Crash Course, 3rd Edition - No Starch Press</a></li> <li><a href="https://mostlypython.substack.com/">Mostly Python - Eric Matthes</a></li> </ul> <p>Level up your Python skills with our expert-led courses:</p> <ul> <li><a href="https://realpython.com/courses/packaging-with-pyproject-toml/">Everyday Project Packaging With pyproject.toml</a></li> <li><a href="https://realpython.com/courses/testing-your-code-with-pytest/">Testing Your Code With pytest</a></li> <li><a href="https://realpython.com/courses/python-assert-statement/">Using Python&#x27;s assert to Debug and Test Your Code</a></li> </ul> <p><a rel="payment" href="https://realpython.com/join">Support the podcast &amp; join our community of Pythonistas</a></p>