[Tutor] unittest: unbound method?
pan at uchicago.edu
pan at uchicago.edu
Sun Nov 14 19:27:07 CET 2004
I have a class Ini that load a dictionary and save
to a config (ini) file. I was trying to write a test
using unittest (this is the first time I use it):
==== code starts =====
from panTools import Ini
class TestIni(unittest.TestCase):
def setUp(self):
self.name = {'First': 'runsun',
'Last' : 'pan'}
def test_loadDict(self):
Ini.load(self.name) #<===========
if __name__ == '__main__':
unittest.main()
==== code ends ====
When executed, it resulted in an error:
in test_loadDict
#x=Ini.load(self.name)
TypeError: unbound method load() must be called with Ini instance as first
argument (got dict instance instead)
I read several unittest tutorials and they all use class.method,
not instance.method. What's going wrong in my code?
Thx in advance.
pan
More information about the Tutor
mailing list