MCPcopy Index your code
hub / github.com/python/cpython / StdoutGuard

Class StdoutGuard

Lib/test/test_descr.py:4783–4786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4781 def test_file_fault(self):
4782 # Testing sys.stdout is changed in getattr...
4783 class StdoutGuard:
4784 def __getattr__(self, attr):
4785 sys.stdout = sys.__stdout__
4786 raise RuntimeError(f"Premature access to sys.stdout.{attr}")
4787
4788 with redirect_stdout(StdoutGuard()):
4789 with self.assertRaises(RuntimeError):

Callers 1

test_file_faultMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_file_faultMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…