From: Scott Gasch Date: Sun, 29 May 2022 22:06:35 +0000 (-0700) Subject: Convert comment into doctest. X-Git-Url: https://wannabe.guru.org/gitweb/?a=commitdiff_plain;h=0fec151ee0b3596016d7a094af13085ef01a8bb4;p=python_utils.git Convert comment into doctest. --- 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 """