209: Testing argparse Applications
How do you test the argument parsing bit of an application that uses argparse?
This episode covers:
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:
- Blog post: Testing argparse Applications
- Code Repo
The Complete pytest Course
- Level up your testing skills and save time during coding and maintenance.
- Check out courses.pythontest.com
Creators and Guests
![209: Testing argparse Applications](https://img.transistor.fm/GmBvN9TVwjbBQ8IVgvx3QkEMZpthq0tK-iJBh94ymf8/rs:fill:800:800:1/q:60/aHR0cHM6Ly9pbWct/dXBsb2FkLXByb2R1/Y3Rpb24udHJhbnNp/c3Rvci5mbS9zaG93/LzQzMjkxLzE2OTUy/NDgxMTctYXJ0d29y/ay5qcGc.webp)