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

Class Capturing

opencompass/datasets/livecodebench/testing_util.py:54–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52# from https://stackoverflow.com/a/16571630/6416660
53# alternative use redirect_stdout() from contextlib
54class Capturing(list):
55
56 def __enter__(self):
57 self._stdout = sys.stdout
58 sys.stdout = self._stringio = StringIO()
59 # Make closing the StringIO a no-op
60 self._stringio.close = lambda x: 1
61 return self
62
63 def __exit__(self, *args):
64 self.append(self._stringio.getvalue())
65 del self._stringio # free up some memory
66 sys.stdout = self._stdout
67
68
69def only_int_check(val):

Callers 1

run_testFunction · 0.70

Calls

no outgoing calls

Tested by 1

run_testFunction · 0.56