209: Testing argparse Applications

How do you test the argument parsing bit of an application that uses argparse?

This episode covers:
  • Design for Test: Structuring your app or script so it's easier to test.
  • pytest & capsys for testing stdout
  • Adding debug and preview flags for debugging and testing
  • And reverting to subprocess.run if you can't modify the code under test
Also, there's a full writeup and code samples available:

The Complete pytest Course
  • For the fastest way to learn pytest, go to courses.pythontest.com
  • Whether your new to testing or pytest, or just want to maximize your efficiency and effectiveness when testing.

Creators and Guests

Brian Okken
Host
Brian Okken
Software Engineer, also on Python Bytes and Python People podcasts
209: Testing argparse Applications
Broadcast by