On Apr 4, 4:38 am, Peter Otten <__pete...@web.de> wrote: > André wrote: > > Hi everyone, > > > In the hope of perhaps contributing some additional unit tests for > > Python (thus contributing back to the community), I dove in the code > > and found something that should be simple but that I can not wrap my > > head around. > > > In list_tests.py, one finds > > === > > from test import test_support, seq_tests > > > class CommonTest(seq_tests.CommonTest): > > > def test_init(self): > > # Iterable arg is optional > > self.assertEqual(self.type2test([]), self.type2test()) > > # etc. > > === > > > Wanting to figure out what the type2test() method does, I looked in > > seq_tests.py and found the following: > > > === > > class CommonTest(unittest.TestCase): > > # The type to be tested > > type2test = None > > > def test_constructors(self): > > l0 = [] > > l1 = [0] > > l2 = [0, 1] > > > u = self.type2test() > > u0 = self.type2test(l0) > > u1 = self.type2test(l1) > > u2 = self.type2test(l2) > > > # etc. > > === > > No where do I find a definition for the type2test() method - other > > than seeing it as a class variable defined to be None by default. I > > looked in unittest.TestCase and did not see it anywhere. > > > Am I missing something obvious? I would appreciate if someone could > > point me in the right direction. > > Use grep ;) >
I sort of did (use a "find all" from within my editor...) > CommonTest is not run standalone, it is used as a(n abstract) base class for > several other tests that override type2test. > > E. g. in Lib/test/list_tests.py: > > from test import test_support, seq_tests > > class CommonTest(seq_tests.CommonTest): > ... > > And then in Lib/test/test_list.py: > > from test import test_support, list_tests > > class ListTest(list_tests.CommonTest): > type2test = list I can't believe I missed that one. Thank you very much! André > ... > > Peter -- http://mail.python.org/mailman/listinfo/python-list