Test & Code
Test & Code
Brian Okken
209: Testing argparse Applications
16 minutes Posted Nov 16, 2023 at 8:07 pm.
0:00
16:19
Download MP3
Show notes

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:


 Learn pytest

★ Support this podcast on Patreon ★