The Real Python Podcast

Eric Matthes: Maybe Don't Start With Unit Tests


Listen Later

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.

Eric is the author of the popular book Python Crash Course. Early in the development of the book, he decided to introduce testing and added a chapter on testing code with pytest.

Over the past couple of years, Eric has continued to consider when and where to test a project’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.

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.

Course Spotlight: Using Python’s assert to Debug and Test Your Code

In this course, you’ll learn how to use Python’s assert statement to document, debug, and test code in development. You’ll learn how assertions might be disabled in production code, so you shouldn’t use them to validate data. You’ll also learn about a few common pitfalls of assertions in Python.

Topics:

  • 00:00:00 – Introduction
  • 00:01:47 – Submitting talks to conferences
  • 00:04:10 – Don’t start with unit tests!
  • 00:07:35 – How did you start with testing?
  • 00:11:30 – Example of a project needing tests
  • 00:14:54 – Defining types of tests
  • 00:16:44 – Integration vs end-to-end tests
  • 00:19:09 – When should you build tests?
  • 00:22:13 – Trade offs of integration vs unit tests
  • 00:24:05 – Why is there push back on this idea?
  • 00:27:36 – Video Course Spotlight
  • 00:29:09 – Using pytest
  • 00:33:24 – Transcripts project example
  • 00:37:03 – py-image-border project
  • 00:40:29 – Criteria for when you should write unit tests
  • 00:48:51 – How to practice writing tests
  • 00:50:28 – Building an integration test and pytest fixtures
  • 00:55:05 – What’s in the test folder?
  • 00:56:31 – Idea for a PyCon tutorial on implementing tests
  • 00:57:29 – Other pytest advice and parametrization
  • 01:01:13 – Caveats to not starting with unit tests
  • 01:02:30 – pytest documentation and other advice
  • 01:05:23 – How to reach Eric online
  • 01:06:47 – What are you excited about in the world of Python?
  • 01:08:23 – What do you want to learn next?
  • 01:09:48 – What conferences are you attending?
  • 01:10:06 – Thanks and goodbye
  • Show Links:

    • Don’t start with unit tests - by Eric Matthes
    • Sleep Better By Writing Python Tests with Eric Matthes - YouTube
    • Episode #163: Python Crash Course & Learning Enough to Start Creating
    • git-sim: Visually simulate Git operations in your own repos with a single terminal command
    • Manim Community
    • django-simple-deploy
    • Learn the grand staff!
    • py-image-border: Add a border to any image
    • pytest Documentation - Get Started
    • About fixtures - pytest documentation
    • Parametrizing tests - pytest documentation
    • uv: Unified Python packaging
    • Prophet 5 Compact Poly Synth - Sequential
    • PyCon US 2025
    • EuroPython 2025 - July 14th-20th 2025 - Prague, Czech Republic & Remote
    • Python Crash Course, 3rd Edition - No Starch Press
    • Mostly Python - Eric Matthes
    • Level up your Python skills with our expert-led courses:

      • Everyday Project Packaging With pyproject.toml
      • Testing Your Code With pytest
      • Using Python's assert to Debug and Test Your Code
      • Support the podcast & join our community of Pythonistas

        ...more
        View all episodesView all episodes
        Download on the App Store

        The Real Python PodcastBy Real Python

        • 4.7
        • 4.7
        • 4.7
        • 4.7
        • 4.7

        4.7

        134 ratings


        More shows like The Real Python Podcast

        View all
        Hanselminutes with Scott Hanselman by Scott Hanselman

        Hanselminutes with Scott Hanselman

        378 Listeners

        Software Engineering Radio - the podcast for professional software developers by se-radio@computer.org

        Software Engineering Radio - the podcast for professional software developers

        263 Listeners

        The Changelog: Software Development, Open Source by Changelog Media

        The Changelog: Software Development, Open Source

        285 Listeners

        LINUX Unplugged by Jupiter Broadcasting

        LINUX Unplugged

        264 Listeners

        Thoughtworks Technology Podcast by Thoughtworks

        Thoughtworks Technology Podcast

        43 Listeners

        Talk Python To Me by Michael Kennedy

        Talk Python To Me

        584 Listeners

        Software Engineering Daily by Software Engineering Daily

        Software Engineering Daily

        631 Listeners

        Super Data Science: ML & AI Podcast with Jon Krohn by Jon Krohn

        Super Data Science: ML & AI Podcast with Jon Krohn

        296 Listeners

        Python Bytes by Michael Kennedy and Brian Okken

        Python Bytes

        213 Listeners

        Data Engineering Podcast by Tobias Macey

        Data Engineering Podcast

        140 Listeners

        Syntax - Tasty Web Development Treats by Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers

        Syntax - Tasty Web Development Treats

        987 Listeners

        CoRecursive: Coding Stories by Adam Gordon Bell - Software Developer

        CoRecursive: Coding Stories

        185 Listeners

        DataFramed by DataCamp

        DataFramed

        267 Listeners

        Practical AI by Practical AI LLC

        Practical AI

        195 Listeners

        The Stack Overflow Podcast by The Stack Overflow Podcast

        The Stack Overflow Podcast

        63 Listeners