diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-06-16 20:24:52 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-06-16 20:24:52 -0400 |
commit | f2166d89e313f6f0b24ced45f2b31109a0d11a2d (patch) | |
tree | 361e8c7820d1530baf1ab71bf5b5b92c856a5c68 /cmd2/transcript.py | |
parent | dd6f6b166c6929a778675c0b897ce5b8aa348e57 (diff) | |
download | cmd2-git-f2166d89e313f6f0b24ced45f2b31109a0d11a2d.tar.gz |
Updated CHANGELOG and slightly refactored/reorganized comments and code in transcript.py
Diffstat (limited to 'cmd2/transcript.py')
-rw-r--r-- | cmd2/transcript.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/cmd2/transcript.py b/cmd2/transcript.py index 5a115496..316592ce 100644 --- a/cmd2/transcript.py +++ b/cmd2/transcript.py @@ -6,8 +6,8 @@ If the user wants to run a transcript (see docs/transcript.rst), we need a mechanism to run each command in the transcript as a unit test, comparing the expected output to the actual output. -This file contains the classess necessary to make that work. These -classes are used in cmd2.py::run_transcript_tests() +This file contains the class necessary to make that work. This +class is used in cmd2.py::run_transcript_tests() """ import re import unittest @@ -27,27 +27,32 @@ class Cmd2TestCase(unittest.TestCase): """ cmdapp = None - def fetchTranscripts(self): - self.transcripts = {} - for fname in self.cmdapp.testfiles: - tfile = open(fname) - self.transcripts[fname] = iter(tfile.readlines()) - tfile.close() - def setUp(self): if self.cmdapp: - self.fetchTranscripts() + self._fetchTranscripts() # Trap stdout self._orig_stdout = self.cmdapp.stdout self.cmdapp.stdout = utils.StdSim(self.cmdapp.stdout) + def tearDown(self): + if self.cmdapp: + # Restore stdout + self.cmdapp.stdout = self._orig_stdout + def runTest(self): # was testall if self.cmdapp: its = sorted(self.transcripts.items()) for (fname, transcript) in its: self._test_transcript(fname, transcript) + def _fetchTranscripts(self): + self.transcripts = {} + for fname in self.cmdapp.testfiles: + tfile = open(fname) + self.transcripts[fname] = iter(tfile.readlines()) + tfile.close() + def _test_transcript(self, fname: str, transcript): line_num = 0 finished = False @@ -205,8 +210,3 @@ class Cmd2TestCase(unittest.TestCase): # slash is not escaped, this is what we are looking for break return regex, pos, start - - def tearDown(self): - if self.cmdapp: - # Restore stdout - self.cmdapp.stdout = self._orig_stdout |