[Python-3000] Interaction between unittest and keyword argument machinery
collinw at gmail.com
Wed Mar 7 16:53:56 CET 2007
On 3/7/07, Patrick Maupin <pmaupin at gmail.com> wrote:
> > > Because unittest always creates **kwargs, any code path in a C
> > > function which is only executed when the *keywords parameter is NULL
> > > will never be correctly tested from the standard unittest methods.
> > This needs some context; which call from unittest to a C function are
> > you talking about?
> Umm, my broken ones? :) In doing some personal doctesting, I noticed
> an issue in my PEP3101 code with a null pointer, and added a test to
> the unittest code to catch it in preparation for fixing it. My
> unittest code never failed, and I realized that the unittest module
> was always passing down a keyword dictionary, even when no keywords
> were passed to it. I'm sure that most Python C programmers are more
> experienced/careful than I am, but even so, it seems that there are a
> whole class of potential bugs in C functions that unittest cannot
> check for at present, because it always passes a keywords dictionary.
The only place in unittest that uses **kwargs is
TestCase.failUnlessRaises()/assertRaises(); is this the method you're
using when writing your tests? If so, then don't use assertRaises():
just call your function and trap the exception manually.
More information about the Python-3000