Tests
Several code paths in Lib/wave.py are not exercised by Lib/test/test_wave.py. Most of them are error and validation branches reachable through the public API, so they are easy to cover with small, deterministic tests.
Measuring line coverage of Lib/wave.py while running test_wave (via the stdlib trace module) shows the existing suite covers 317 of 449 executable lines. The uncovered branches include, among others:
Wave_write parameter validation
setnchannels() rejecting a non-positive channel count
getnchannels() / getsampwidth() / getframerate() / getparams() when parameters are unset
setsampwidth() rejecting out-of-range widths
setcomptype() / setformat() rejecting unsupported values
- the "cannot change parameters after starting to write" guards on every setter
tell()
Wave_read error handling
- rejecting a
WAVE_FORMAT_EXTENSIBLE file whose SubFormat GUID is not PCM
- raising
EOFError on a truncated fmt chunk
- skipping unknown chunks between
fmt and data
getfp()
- closing the underlying file when opening a malformed file by path fails
wave.open()
- rejecting an invalid mode
Proposal
Add tests covering these paths. This is test-only (no behavior change), so no Misc/NEWS.d entry is required.
I have a patch ready and will open a PR.
Linked PRs
Tests
Several code paths in
Lib/wave.pyare not exercised byLib/test/test_wave.py. Most of them are error and validation branches reachable through the public API, so they are easy to cover with small, deterministic tests.Measuring line coverage of
Lib/wave.pywhile runningtest_wave(via the stdlibtracemodule) shows the existing suite covers 317 of 449 executable lines. The uncovered branches include, among others:Wave_writeparameter validationsetnchannels()rejecting a non-positive channel countgetnchannels()/getsampwidth()/getframerate()/getparams()when parameters are unsetsetsampwidth()rejecting out-of-range widthssetcomptype()/setformat()rejecting unsupported valuestell()Wave_readerror handlingWAVE_FORMAT_EXTENSIBLEfile whose SubFormat GUID is not PCMEOFErroron a truncatedfmtchunkfmtanddatagetfp()wave.open()Proposal
Add tests covering these paths. This is test-only (no behavior change), so no
Misc/NEWS.dentry is required.I have a patch ready and will open a PR.
Linked PRs
wavemodule #153954