Following up on @philnik's suggestion in D116809. Is this too much extra bureaucratic code for too little gain? I'm not sure, but it doesn't seem like a crazy amount of bureaucratic code.
Here, as in D116809, I'm assuming that Python3 string comparisons (for ASCII characters) are sane and unaffected by locale in any way that would harm us. It'd be awesome if some Python guru could confirm or deny that.
Note that the fact that we'd be running tests as part of a target that generates files is what got me to suggest the alternative approach with a shell test.