summaryrefslogtreecommitdiff
path: root/cmd2/transcript.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-25 18:16:22 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-25 18:16:22 -0400
commit45d2398b3023543ed1615115db5d35b1fd65dc5b (patch)
treec2af42bab5f3aacdd507dcaea801581a306d0a92 /cmd2/transcript.py
parent7cc94ab98c007210b344fbb1af965570fae63959 (diff)
parentdac03119e5932f8a34a1318122e2f45fa875084c (diff)
downloadcmd2-git-45d2398b3023543ed1615115db5d35b1fd65dc5b.tar.gz
Merge branch 'master' into command_help_noflag
Diffstat (limited to 'cmd2/transcript.py')
-rw-r--r--cmd2/transcript.py23
1 files changed, 1 insertions, 22 deletions
diff --git a/cmd2/transcript.py b/cmd2/transcript.py
index 8df58634..2d94f4e4 100644
--- a/cmd2/transcript.py
+++ b/cmd2/transcript.py
@@ -44,7 +44,7 @@ class Cmd2TestCase(unittest.TestCase):
# Trap stdout
self._orig_stdout = self.cmdapp.stdout
- self.cmdapp.stdout = OutputTrap()
+ self.cmdapp.stdout = utils.StdSim(self.cmdapp.stdout)
def runTest(self): # was testall
if self.cmdapp:
@@ -203,24 +203,3 @@ class Cmd2TestCase(unittest.TestCase):
if self.cmdapp:
# Restore stdout
self.cmdapp.stdout = self._orig_stdout
-
-class OutputTrap(object):
- """Instantiate an OutputTrap to divert/capture ALL stdout output.
- For use in transcript testing.
- """
-
- def __init__(self):
- self.contents = ''
-
- def write(self, txt: str):
- """Add text to the internal contents."""
- self.contents += txt
-
- def read(self) -> str:
- """Read from the internal contents and then clear them out.
-
- :return: str - text from the internal contents
- """
- result = self.contents
- self.contents = ''
- return result