
On Feb 17, 2012 3:58 PM, "Mark Janssen" <dreamingforward@gmail.com> wrote:
I dunno... I find the discipline of defining your prerequesites to be a helpful feature of doctest (I find TestCase.setUp to be smelly). You can include a namespace in doctest invocations, but I'm guessing the problem is that you aren't able to give these settings when using some kind of test collector/runner? More flexible ways of defining doctest options (e.g., ELLIPSIS) would be helpful.
Without #2, "readable docs" nicely co-aligning with "testable docs" tends towards divergence.
IMHO this could be more easily solved by replacing the standard repr with one that is more predictable. At least that would handle dictionaries, it becomes a bit more difficult for custom types. Also it diverges from being exactly like the console, but eh, I don't think that's a big advantage. Unfortunately plugging in a custom repr is kind of hard; Python has a way to specifically compile expressions into "print repr(expr)" (more or less) but no general way to get the value of expressions (while also handling statements). But if you wanted to try it, I did figure out a terrible hack for it. Ian
participants (2)
-
Guido van Rossum
-
Ian Bicking