diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-24 10:35:41 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-24 10:35:41 -0400 |
commit | c8a9a7a9d99c50b069a848a78ac41b2c3de0f7e1 (patch) | |
tree | 34d346b2ccf7a0edfc3cc6e2ec08bc840b8fa944 /cmd2/transcript.py | |
parent | fedc201a772ad8358a0d6220d1e2020c4db7a9c1 (diff) | |
parent | e5e8a7954b9ace78cd49ef43c5f8d6203c227f0f (diff) | |
download | cmd2-git-c8a9a7a9d99c50b069a848a78ac41b2c3de0f7e1.tar.gz |
Merge branch 'master' into macro
Diffstat (limited to 'cmd2/transcript.py')
-rw-r--r-- | cmd2/transcript.py | 23 |
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 |