The Real Python Podcast

Building Python Unit Tests & Exploring a Data Visualization Gallery

5 snips
May 31, 2024
Python expert Christopher Trudeau discusses adding unit tests to Python code using the unittest framework, covering organizing tests, assert methods, fixtures, and debugging. They also explore Python data visualizations from the Python Graph Gallery, showcasing tutorials for different chart types. Other topics include Python 3.13 features, pytest speed improvements, software friction, Raspberry Pi document scanner, and time per iteration loop control project.
Ask episode
AI Snips
Chapters
Transcript
Episode notes
ADVICE

Start With unittest Before Adding Tools

  • Use Python's built-in unittest for comprehensive testing before adding external frameworks.
  • Organize tests with TestCase, fixtures, and assert methods to cover edge cases and debug failures.
ADVICE

Skip Tests Strategically

  • Skip flaky or platform-specific tests using unittest.skip and skipIf decorators.
  • Use these decorators to keep test runs meaningful across environments and Python versions.
INSIGHT

Assert Variety Enables Precise Tests

  • unittest exposes many assert methods beyond assertEqual, including identity, membership, and exception checks.
  • These varied asserts let you express precise expectations without extra libraries.
Get the Snipd Podcast app to discover more snips from this episode
Get the app