On Fri, 15 Apr 2016 10:48 pm, Antoon Pardon wrote: > Starting from this: > > class Test_AVLTree(unittest.TestCase): > > def test_empty_tree_is_false(self): > instance = avltree() > self.assertFalse(instance) > > Changing it into this: > > def MakeAVLTest(avltree): > class Test_AVLTree(unittest.TestCase): > > def test_empty_tree_is_false(self): > instance = avltree() > self.assertFalse(instance) > > return Test_AVLTree > > AVLTest = MakeAVLTest(avltree) > MyTreeTest = MakeAVLTest(mytree) > > Seems to work
Right up to the moment that you realise that you need different tests for a subclass, and now you can't using subclassing because they aren't subclasses, they're completely independent classes that happen to duplicate the same methods. If the tests for your AVL tree and it's subclasses are *identical*, then what's the point of the subclasses? -- Steven -- https://mail.python.org/mailman/listinfo/python-list