Repository navigation
Add python-cli-testing materials folder - #973
Merged
Merged
Conversation
Companion code for the tutorial 4 Techniques for Testing Python Command-Line (CLI) Apps: the buggy starting app and its pytest unit test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the companion code for 4 Techniques for Testing Python Command-Line (CLI) Apps, under the standing rule that every tutorial with runnable code gets a materials folder and a sample-code opt-in.
Files
testapp.py: the tutorial's starting app, with its deliberate bugs. Running it raisesKeyError: 'parents', as the article shows. The run loop sits under anif __name__ == "__main__":guard sopytestcan import the module.test_testapp.py: the article'sgenerate_initial_transform_parametersfixture andtest_initial_transform().requirements.txt:pytest==9.1.1, the same pin as the article'sdependenciesfield.README.md: setup and usage. The Python 3.10 floor comes from pytest 9.1.1'sRequires-Python(vermin reports 3.0 for the code itself).The mock snippets aren't included. They patch a hypothetical
outside_moduleand needpytest-mock, which the article doesn't pin.Verification (Python 3.14, venv built from
requirements.txt)python testapp.pyends inKeyError: 'parents', which matches the article's traceback.pytest: 1 passed (nodict), 1 failed (dict). That's the intended state before the Unit Test Exercise.initial_transform(), both tests pass.ruff format --check,ruff check(0.14.1), anddircheck.pyall pass.Links
🤖 Generated with Claude Code