summaryrefslogtreecommitdiff
path: root/cmd2/transcript.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-09-30 11:17:04 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-09-30 11:17:04 -0400
commit81ad085cffc8f8af7fb7884bcc5db6fcede09df6 (patch)
treea197a6c81767f10b62d6ac6acfd46e42357a8289 /cmd2/transcript.py
parent85a21ef39467dc24a6f6f8c4f3ac656f24d6ff90 (diff)
parent61d5703cd3586b3460669a6260cf903c9863b240 (diff)
downloadcmd2-git-81ad085cffc8f8af7fb7884bcc5db6fcede09df6.tar.gz
Merged master into transcript_fixes branch and resolved conflicts
Diffstat (limited to 'cmd2/transcript.py')
-rw-r--r--cmd2/transcript.py25
1 files changed, 2 insertions, 23 deletions
diff --git a/cmd2/transcript.py b/cmd2/transcript.py
index 5ba8d20d..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:
@@ -106,7 +106,7 @@ class Cmd2TestCase(unittest.TestCase):
self.assertTrue(re.match(expected, result, re.MULTILINE | re.DOTALL), message)
def _transform_transcript_expected(self, s: str) -> str:
- """Parse the string with slashed regexes into a valid regex.
+ r"""Parse the string with slashed regexes into a valid regex.
Given a string like:
@@ -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