Skip to main content

doctest really isn't very good

·1 min

I just got sick of trying to decode obtuse doctest diff errors when using NORMALIZE_WHITESPACE and ELLIPSIS options. Although doctest gives you hooks to do something about this, it’s really hard to actually write the logic.

See, NORMALIZE_WHITESPACE also normalizes line breaks, and ‘…’ can match across multiple lines. That means that you can’t take a line-based approach, which makes it really hard to clean up a diff. Anyway, here’s my attempt:

It’s a pain, because both of them would be very useful without their line-spanning behaviour. I guess without the line-spanning behaviour of ‘…’ there’d be no way to indicate multiple lines of crap in output.

My suggestion in the mean time? Don’t use doctest.