def loadTestsFromTestClass(self, cls): """ Manually examine test class for inner classes. """ results = [] for name, subclass in class_members(cls): results.extend(self.loader.loadTestsFromTestClass(subclass)) return results
def registerGoodClass(self, class_): """ Internal bookkeeping to handle nested classes """ # Class itself added to "good" list self._valid_classes.append(class_) # Recurse into any inner classes for name, cls in class_members(class_): if self.isValidClass(cls): self.registerGoodClass(cls)
def autohide(obj): """ Automatically hide setup() and teardown() methods, recursively. """ # Members on obj for name, item in six.iteritems(vars(obj)): if callable(item) and name in ('setup', 'teardown'): item = hide(item) # Recurse into class members for name, subclass in class_members(obj): autohide(subclass)
def flag_inner_classes(obj): """ Mutates any attributes on ``obj`` which are classes, with link to ``obj``. Adds a convenience accessor which instantiates ``obj`` and then calls its ``setup`` method. Recurses on those objects as well. """ for tup in class_members(obj): tup[1]._parent = obj tup[1]._parent_inst = None tup[1].__getattr__ = my_getattr flag_inner_classes(tup[1])