DiscoverTest & Code209: Testing argparse Applications
209: Testing argparse Applications

209: Testing argparse Applications

Update: 2023-11-16
Share

Description

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

Comments 
loading
00:00
00:00
1.0x

0.5x

0.8x

1.0x

1.25x

1.5x

2.0x

3.0x

Sleep Timer

Off

End of Episode

5 Minutes

10 Minutes

15 Minutes

30 Minutes

45 Minutes

60 Minutes

120 Minutes

209: Testing argparse Applications

209: Testing argparse Applications

Brian Okken