Characterization Tests Must Freeze Subprocess Results Before Any Code Extraction
Developers refactoring subprocess wrappers risk breaking callers if they extract helper functions without first recording a stable snapshot of process results. Characterization tests must capture returncode, stdout and stderr types, exception class names, and timeout values for every fixture command before any code change is made. A wrapper that mixes shell, check, and text flags can silently change exception types from TimeoutExpired to CalledProcessError after an unguarded extract. The recommended approach involves running a recorder script against the live wrapper to generate JSON fixture files, which then serve as the source of truth for pytest-based characterization tests. Only once all tests remain green against those committed JSON records should any refactoring of the subprocess wrapper proceed.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in