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
Sponsored by:
- The Complete pytest course is now a bundle, with each part available separately.
- pytest Primary Power teaches the super powers of pytest that you need to learn to use pytest effectively.
- Using pytest with Projects has lots of "when you need it" sections like debugging failed tests, mocking, testing strategy, and CI
- Then pytest Booster Rockets can help with advanced parametrization and building plugins.
- Whether you need to get started with pytest today, or want to power up your pytest skills, PythonTest has a course for you.
Creators and Guests
