[Python-ideas] doctest

Steven D'Aprano steve at pearwood.info
Sat Feb 18 06:08:16 CET 2012


Mark Janssen wrote:
> I find myself wanting to use doctest for some test-driven development,
> and find myself slightly frustrated and wonder if others would be
> interested in seeing the following additional functionality in
> doctest:
> 
> 1. Execution context determined by outer-scope doctest defintions.

Can you give an example of how you would like this to work?


> 2. Smart Comparisons that will detect output of a non-ordered type
> (dict/set), lift and recast it and do a real comparison.

I would love to see a doctest directive that accepted differences in output 
order, e.g. would match {1, 2, 3} and {3, 1, 2}. But I think that's a hard 
problem to solve in the general case. Should it match 123 and 312? I don't 
think so.

Just coming up with a clear and detailed set of requirements for (e.g.) 
#doctest:+IGNORE_ORDER may be tricky.


I'd like a #3 as well: an abbreviated way to spell doctest directives, because 
they invariably push my tests well past the 80 character mark.



-- 
Steven




More information about the Python-ideas mailing list