tuna: Argparse refactoring and testing improvements
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest5 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | tuna: Replace bare except clauses with specific exception typestuna-cmd.py | +8 | 0 replies | |
| 2/5 | tuna: Eliminate side effects from argparse by deferring type conversionstuna-cmd.py | +39 | 0 replies | |
| 3/5 | tuna: Eliminate global ps and irqs variablestuna-cmd.py | +13 | 0 replies | |
| 4/5 | tuna: Add .local/ directory to .gitignore.gitignore | +1 | 0 replies | |
| 5/5 | tuna: Add tests for converter functions and update test READMEtests/ tests/ | +241 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/5] tuna: Argparse refactoring and testing improvements
This series refactors the argparse implementation in tuna-cmd.py to eliminate side effects during argument parsing and remove global variables, making the code more maintainable and testable.
The main improvements are:
1. Replace bare except clauses with specific exception types for better error handling
2. Defer type conversions until after parsing completes, eliminating side effects during argument parsing (parse → convert → execute pattern)
3. Remove global variables (ps, irqs, match_requested) and pass them as function parameters instead
4. Add comprehensive unit tests (12 tests) for argument converter functions using mock objects to avoid requiring procfs access
5. Update test documentation with detailed examples and explanations
All tests pass (18 total) and run without requiring root privileges.
John Kacur (5):
tuna: Replace bare except clauses with specific exception types
tuna: Eliminate side effects from argparse by deferring type
conversions
tuna: Eliminate global ps and irqs variables
tuna: Add .local/ directory to .gitignore
tuna: Add tests for converter functions and update test README
.gitignore | 1 + tests/README.md | 85 ++++++++++++++++++++- tests/test_converters.py | 160 +++++++++++++++++++++++++++++++++++++++ tuna-cmd.py | 114 ++++++++++++++-------------- 4 files changed, 300 insertions(+), 60 deletions(-) create mode 100644 tests/test_converters.py
Signature · 1 line
2.54.0