def captureOutput(): oldout, olderr = sys.stdout, sys.stderr try: out = [StringIO(), StringIO()] sys.stdout, sys.stderr = out yield out finally: sys.stdout, sys.stderr = oldout, olderr out[0] = out[0].getvalue() out[1] = out[1].getvalue()
def __call__(self): old_stderr = sys.stderr sys.stderr = mystderr = StringIO() test_dir = ytcfg.get("yt", "test_data_dir") answers_dir = os.path.join(test_dir, "answers") if '--with-answer-testing' in self.argv and \ not os.path.isdir(os.path.join(answers_dir, self.name)): nose.run(argv=self.argv + ['--answer-store'], addplugins=[AnswerTesting()], exit=False) if os.path.isfile("{}.xml".format(self.name)): os.remove("{}.xml".format(self.name)) nose.run(argv=self.argv, addplugins=[AnswerTesting()], exit=False) sys.stderr = old_stderr return mystderr.getvalue()