Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Unittest and dynamically created methods

Reply
Thread Tools

Unittest and dynamically created methods

 
 
JAWS
Guest
Posts: n/a
 
      10-14-2003
I get this error message when trying to run a unittest test with a
dynamically created test method:

Traceback (most recent call last):
File "unittest.py", line 215, in __call__
testMethod()
TypeError: ?() takes no arguments (1 given)


I have no clue as to where the 1 given argument comes from...
I am using python 2.2 and here is a copy of the code generating this:

#! /bin/env python

import unittest, commands, new

class Test(unittest.TestCase):
done = None

def initialization(self):
Test.port = 11000
Test.host = 'meadow'

def setUp(self):
if not Test.done:
Test.done = 1
Test.initialization(self)

def tearDown(self):
pass

def testCommandFailure(self):
status, output = commands.getstatusoutput('python
.../bin/uimClient.py' +
' -p ' + str(Test.port) + ' -h ' + Test.host)
self.assertEqual(256, status)

def testCommandFailure3(self):
status, output = commands.getstatusoutput('python
.../bin/uimClient.py' +
' -p ' + str(Test.port) + ' -h ' + Test.host)
self.assertEqual(256, status)

#====================================BASE
TEST==================================

if __name__ == '__main__':

base = 'def testCommandFailure2(self):\n\t""" Testing test1 method
"""' +\
'\n\tstatus, output = commands.getstatusoutput("python " +' + \
'" ../bin/uimClient.py -p " + str(Test.port) + " -h " +
Test.host)'+\
'\n\tself.assertEqual(status, 256)\n'
code = compile(base, 'uimClientFT.py', 'exec')
testf = new.function(code, Test.__dict__, 'testCommandFailure2')
setattr(Test, 'testCommandFailure2', testf)

print Test.__dict__
print type(Test.testCommandFailure2)

unittest.main()



J-P
thankx

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
Unittest and dynamically created methods JAWS Python 2 10-15-2003 08:34 AM
Unittest and dynamically created methods JAWS Python 0 10-14-2003 07:46 PM
Unittest and dynamically created methods JAWS Python 0 10-14-2003 07:43 PM
Unittest and dynamically created methods JAWS Python 0 10-14-2003 07:42 PM



Advertisments