def _gatherTestCasesFromCallerByMagic(): # UGLY magic: fetch TestClass subclasses from the globals of our # caller's caller. frame = sys._getframe(2) return _gatherTestCasesFromDict(frame.f_globals)