MCPcopy Index your code
hub / github.com/RustPython/RustPython / stream_context

Method stream_context

Lib/test/test_android.py:95–113  ·  view source on GitHub ↗
(self, stream_name, level)

Source from the content-addressed store, hash-verified

93 # test them directly. Detect this mode and use some temporary streams with
94 # the same properties.
95 def stream_context(self, stream_name, level):
96 # https://developer.android.com/ndk/reference/group/logging
97 prio = {"I": 4, "W": 5}[level]
98
99 stack = ExitStack()
100 stack.enter_context(self.subTest(stream_name))
101 stream = getattr(sys, stream_name)
102 native_stream = getattr(sys, f"__{stream_name}__")
103 if isinstance(stream, io.StringIO):
104 stack.enter_context(
105 patch(
106 f"sys.{stream_name}",
107 TextLogStream(
108 prio, f"python.{stream_name}", native_stream.fileno(),
109 errors="backslashreplace"
110 ),
111 )
112 )
113 return stack
114
115 def test_str(self):
116 for stream_name, level, fileno in STREAM_INFO:

Callers 2

test_strMethod · 0.95
test_bytesMethod · 0.95

Calls 8

ExitStackClass · 0.90
patchFunction · 0.90
TextLogStreamClass · 0.90
getattrFunction · 0.85
isinstanceFunction · 0.85
enter_contextMethod · 0.80
subTestMethod · 0.80
filenoMethod · 0.45

Tested by

no test coverage detected