Doctest examples

Has anyone here found some helpful uses of the doctest test module? I’m looking at the doctest docs. It’s interesting because it looks like it’s meant to handle exceptions. What I don’t understand is, if you’re generating the docstring from loading your module at the interepreter, won’t your doctest miss on any flaws because it’s producing the same output as what’s in your docstring?

What I mean is, doctest is basically doing the same test that you are doing, using your code. If your code is flawed, the doctest will be flawed too, and that means doctest will not tell you there’s a problem. It only tells you there’s a problem if the output it gets is different from your docstring

Here are the sites I’ve been reading on doctest

Not really. I think doctest is an alright idea, but in practice it only works for things that you can work with inside a python shell. That’s not very many things that you need to test, and it’s just more code to maintain.