Not completely necessary: here it's OK if the assert is removed by `python -O`, as it's a guard against programming error and not a test assert.