[TIP] How do I run the same test on many different classes?

Matthew Wilson matt at tplus1.com
Sun Dec 13 12:07:34 PST 2009


On Sun, Dec 13, 2009 at 3:02 PM, ssteinerX at gmail.com
<ssteinerx at gmail.com> wrote:
>
> On Dec 13, 2009, at 2:45 PM, Matthew Wilson wrote:
>
>> This is one of those problems that I know how to solve in an ugly way,
>> but I want to learn a better way.
>
> What's the ugly way?

Copy and paste my TestTask for each Task1, Task2, etc, like this:

class TestTask1(TestTask):
    def setUp(self):
        self.t = Task1()

class TestTask2(TestTask):
     def setUp(self):
        self.t = Task2()


Seems a little ironic to me that it is so hard to pass in a parameter
to a test, since using parameters rather than making objects
internally is so useful for writing testable code :)

Matt

-- 
W. Matthew Wilson
matt at tplus1.com
http://tplus1.com



More information about the testing-in-python mailing list