unittest.TestCase and functools.partial don't seem to mix
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Wed Oct 7 10:51:11 EDT 2009
En Tue, 06 Oct 2009 18:01:34 -0300, Joel Smith <js-pythonlist at jk1.net>
escribió:
> Gabriel Genellina wrote:
>> Note that you don't *have* to use partial in this case, as you're
>> building the suite yourself. Just create the TestCase instances
>> manually:
>>
>> suite = unittest.TestSuite([
>> TestGenericWindow('testit', 'brown'),
>> TestGenericWindow('testit', 'blue'),
>> TestGenericWindow('testit', 'green')
>> ])
>> unittest.TextTestRunner().run(suite)
>
> Perfect! This is exactly what I needed. For some reason, I didn't
> understand that I could construct my TestCase objects directly... I
> thought that I had to allow the unittest framework to construct them for
> me. This is straightforward, and does exactly what I need.
You're not alone :) The unittest design is rather convoluted, probably
because it aims to mimic the jUnit design as closely as possible, with all
its javaism and unpythonicity. I don't think one could understand how to
use the framework just by reading the package documentation; more
background info is needed. The "Dive into Python" book contains a chapter
on this topic.
--
Gabriel Genellina
More information about the Python-list
mailing list