- Commit messages should use present imperative, first describing any problem or motivation in its own paragraph, then what the patch does. The current source is how things are now, not how they were
- Keep identifiers short. If there's only one 'part' in a function, call it
part, notallocated_part - Prefer short function names:
exec_cmdnotrun_or_show_command,build_descnotappend_tags_to_description - Avoid
getattr(args, 'foo', default)when the attribute is guaranteed to exist; useargs.foodirectly
- Run tests with:
python -m pytest uman_pkg/ftest.py -v - Run pylint with:
python3 -m pylint uman_pkg/ftest.py
- Use
terminal.capture() as (out, err)for tuple unpacking, notas out - Keep capture blocks minimal - only wrap the code that produces output
- Put expected value first in asserts:
self.assertEqual(expected, actual) - Use
assertFalse(out.getvalue())for checking empty output, notassertEqual('', ...) - Check both stdout and stderr in all captures
- Check full output strings, not partial matches with assertIn
- Use
orig_prefix for saved values, notoriginal_ - Use
command.TEST_RESULTfor mocking command execution, restore in tearDown - Put
tout.init()in setUp(), not inside individual tests - Put assertRaises outside terminal.capture so test failures show output
- Use
cmdline.parse_args(['cmd', 'arg'])in tests instead ofargparse.Namespace(...)