MCPcopy Create free account
hub / github.com/InternScience/SciReason / Capturing

Class Capturing

opencompass/datasets/taco.py:279–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277# from https://stackoverflow.com/a/16571630/6416660
278# alternative use redirect_stdout() from contextlib
279class Capturing(list):
280
281 def __enter__(self):
282 self._stdout = sys.stdout
283 sys.stdout = self._stringio = StringIO()
284 # Make closing the StringIO a no-op
285 self._stringio.close = lambda x: 1
286 return self
287
288 def __exit__(self, *args):
289 self.extend(self._stringio.getvalue().splitlines())
290 del self._stringio # free up some memory
291 sys.stdout = self._stdout
292
293
294def run_test(sample, test=None, debug=False):

Callers 1

run_testFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected