[pyatl] Running unittest.py with input parameters. Possible?

From: Filipe P.
Sent on: Saturday, August 29, 2009 4:30 PM

Hi,

 

I'm trying to beef up my testing. I'm running into an issue, to which some of you might already resolved with a killer strategy(so I hope).

 

All the testing examples that use the unittest lib, have methods that DON'T take any input parameters.

 

 

class TestCase(unittest.TestCase):

   

    def test00001(self):

        '''

          Doc strings

        '''

        pass

 

 

if __name__ == "__main__":

    #unittest.main()

    my_test = GodaddyServiceTestCase(test00001)

    my_test.run()

 

 

What I’m trying to do is to call my test functions with different parameters, by defining them with input parameters.  Here’s the example:

 

class TestCase():

   

    def test0002(self,debug = False, name=DEFAULT_ NAME):

        '''

        '''

   

        print self.test0002.__doc__

        print 'Arguments:\n-debug: %s\n-domain: %s' % (str(debug), name)

 

 

if __name__ == "__main__":

    my_test = TestCase()

    my_test.test0002(debug=False, name='test')

 

As you for sure noticed, in the above parameter, I no longer inherit from unittest.TestCase because I don’t know how I would call the method and pass the input parameters.

 

I understand that testing requires TONS of knowledge, and I’m sure some of you have the solution for this issue (or a suggestion on how I could do it in a far better way).

 

Care to share it with me?

 

Thanks a bunch!

 

Filipe

 

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy