def _context(self): try: return self.test.context except AttributeError: pass try: return self.test.__class__ except AttributeError: pass try: return resolve_name(self.test.__module__) except AttributeError: pass return None
def ancestry(self, context): """Return the ancestry of the context """ if context is None: return if hasattr(context, 'im_class'): context = context.im_class if hasattr(context, '__module__'): ancestors = context.__module__.split('.') elif hasattr(context, '__name__'): ancestors = context.__name__.split('.')[:-1] else: raise TypeError("%s has no ancestors?" % context) while ancestors: yield resolve_name('.'.join(ancestors)) ancestors.pop()
def _context(self): return resolve_name(self.test.__module__)