Unittest - How do I code lots of simple tests

Garth T Kidd garth at deadlybloodyserious.com
Thu Oct 23 11:59:19 EDT 2003


> Take a look at Docutils' test/DocutilsTestSupport.py for ideas.  The
> CustomTestSuite and CustomTestCase classes provide support for named
> data-driven tests.  Most of Docutils' tests are data-driven.

Ha! You beat me to it. And here I was ready to post my article on self-
loading test suites: 

    http://www.pycs.net/users/0000088/stories/7.html

Apart from the default TestLoader not picking up TestSuite subclasses, 
which can be fixed with a modified main test running script, it all 
works pretty well. 

> Ian Bicking wrote:
>  > unittest is not written with subclassing in mind, except for the
>  > limited subclassing that is documented.  (And it uses
>  > double-underscore variables, like it's just *trying* to piss me off!
>  > Double-underscore variables are so arrogant and patronizing.
> 
> All very true.  Double-underscores ought to be banned from the
> standard library.  They inevitably get in the way because no matter
> how well a class is written, somebody is going to want to subclass it
> in a way the original author never considered.

Amen to that. I complain in my article about having to hack around 
unittest's double-underscored attributes. Worse, I never found a way to 
call double-underscored methods. Bah humbug. 

Back to tests, though; I imagine it wouldn't take much to merge a few of 
these wheel implementations and produce a new, improved unittest. 

Regards,
Garth.




More information about the Python-list mailing list