diff options
| author | Scott Gasch <[email protected]> | 2022-05-29 15:06:35 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2022-05-29 15:06:35 -0700 |
| commit | 0fec151ee0b3596016d7a094af13085ef01a8bb4 (patch) | |
| tree | 64e9fbbb0ea07b6ccb7b52ec13c489df4e0ac441 | |
| parent | 62b4b777a68a99c8e446294f7e7e35ebd9668989 (diff) | |
Convert comment into doctest.
| -rw-r--r-- | string_utils.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/string_utils.py b/string_utils.py index dbd50f2..88fc910 100644 --- a/string_utils.py +++ b/string_utils.py @@ -1247,16 +1247,15 @@ def strip_ansi_sequences(in_str: str) -> str: class SprintfStdout(contextlib.AbstractContextManager): """ A context manager that captures outputs to stdout to a buffer - without printing them. e.g.:: + without printing them. - with SprintfStdout() as buf: - print("test") - print("1, 2, 3") - print(buf()) - - This yields:: - - 'test\\n1, 2, 3\\n' + >>> with SprintfStdout() as buf: + ... print("test") + ... print("1, 2, 3") + ... + >>> print(buf(), end='') + test + 1, 2, 3 """ |
