Commit b538845
committed
Cover pixelunshuffle()'s indivisible-dimension error path
pixelunshuffle() raises ValueError when a spatial dimension is not
divisible by the scale factor. Nothing exercised that branch: the five
existing tests all use shapes that divide cleanly, so the guard clause
and its message were never executed by the suite. That is why the
malformed message corrected in the preceding commit survived from
March 2025 without anyone noticing.
This test covers that branch, and is written so it would have caught
that specific defect. The wording of the assertion is load-bearing, not
incidental, because the malformed code raises ValueError too:
assertRaises(ValueError) alone passes on the broken message
match "divisible by factor" passes on the broken message
match "factor 2, spatial" fails on the broken message
Only a pattern spanning the point where the two literals were joined can
tell the two apart, so the assertion has to reach across it. Against the
unfixed source it reports:
AssertionError: "divisible by factor 2, spatial shape is: \[7, 8\]"
does not match "All spatial dimensions must be divisible by factor
2. , spatial shape is: [7, 8]"
The trade-off is that the test is coupled to the message text and will
need updating if the message is reworded. That is the cost of pinning
the defect; a looser assertion would pass either way and prove nothing.
Kept as a separate commit so the text corrections can be reviewed, or
reverted, independently of the new coverage.
Signed-off-by: Hans Johnson <hans-johnson@uiowa.edu>1 parent 4af24d7 commit b538845
1 file changed
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
0 commit comments