def run(self, result):
topLevel = False<EOL>if getattr(result, '<STR_LIT>', False) is False:<EOL><INDENT>result._testRunEntered = topLevel = True<EOL><DEDENT>for index, test in enumerate(self):<EOL><INDENT>if result.shouldStop:<EOL><INDENT>break<EOL><DEDENT>if _isnotsuite(test):<EOL><INDENT>self._tearDownPreviousClass(test, result)<EOL>self._handleModuleFixture(test, result)<EOL>self._handleClassSetUp(test, result)<EOL>result._previousTestClass = test.__class__<EOL>if (getattr(test.__class__, '<STR_LIT>', False) or<EOL>getattr(result, '<STR_LIT>', False)):<EOL><INDENT>continue<EOL><DEDENT>if not self.allow_stdout:<EOL><INDENT>captured_stdout = StringIO()<EOL>captured_stderr = StringIO()<EOL>saved_stdout = sys.stdout<EOL>saved_stderr = sys.stderr<EOL>sys.stdout = GreenStream(captured_stdout)<EOL>sys.stderr = GreenStream(captured_stderr)<EOL><DEDENT><DEDENT>test(result)<EOL>if _isnotsuite(test):<EOL><INDENT>if not self.allow_stdout:<EOL><INDENT>sys.stdout = saved_stdout<EOL>sys.stderr = saved_stderr<EOL>result.recordStdout(test, captured_stdout.getvalue())<EOL>result.recordStderr(test, captured_stderr.getvalue())<EOL><DEDENT>result.finalize()<EOL><DEDENT>self._removeTestAtIndex(index)<EOL><DEDENT>if topLevel:<EOL><INDENT>self._tearDownPreviousClass(None, result)<EOL>self._handleModuleTearDown(result)<EOL>result._testRunEntered = False<EOL><DEDENT>return result<EOL>
Emulate unittest's behavior, with Green-specific changes.