Convert comment into doctest.
authorScott Gasch <[email protected]>
Sun, 29 May 2022 22:06:35 +0000 (15:06 -0700)
committerScott Gasch <[email protected]>
Sun, 29 May 2022 22:06:35 +0000 (15:06 -0700)
string_utils.py

index dbd50f22bbe48b349dd69649f480a557cb7ba1c7..88fc91011042514f554a77ab5906491888d0c5e1 100644 (file)
@@ -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
 
     """