def test_alternative_constructor(self): elem = self.element elem.nodes = ChildSubset.class_preconstructor(tag_regex=r'node') elem.nodes = elem.nodes(elem) # why doesn't this work? it should just work w/ elem.nodes(). It works ..inside.. the instance, but not outside? self.assertIsInstance(elem.nodes, ChildSubset)
def test_add_preconstructed_subset_to_element_class(self): mme.BaseElement.nodes = ChildSubset.class_preconstructor(tag_regex=r'node') e = mme.BaseElement() self.assertTrue(hasattr(e, 'nodes')) del mme.BaseElement.nodes # be sure to remove this class variable