(self, stream_name, level)
| 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: |
no test coverage detected