MCPcopy Create free account
hub / github.com/RUC-NLPIR/WebThinker / Capturing

Class Capturing

scripts/lcb_runner/evaluation/testing_util.py:57–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

run_testFunction · 0.85

Calls

no outgoing calls

Tested by 1

run_testFunction · 0.68