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 | |
parent | dd6f6b166c6929a778675c0b897ce5b8aa348e57 (diff) | |
download | cmd2-git-f2166d89e313f6f0b24ced45f2b31109a0d11a2d.tar.gz |
Updated CHANGELOG and slightly refactored/reorganized comments and code in transcript.py
-rw-r--r-- | CHANGELOG.md | 7 | ||||
-rw-r--r-- | cmd2/transcript.py | 30 |
2 files changed, 19 insertions, 18 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index a07c5198..8abe6a6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.9.14 (TBD, 2019) * Enhancements * Added support for and testing with Python 3.8, starting with 3.8 beta + * Improved information displayed during transcript testing * Breaking Changes * Python 3.4 reached its [end of life](https://www.python.org/dev/peps/pep-0429/) on March 18, 2019 and is no longer supported by `cmd2` * If you need to use Python 3.4, you should pin your requirements to use `cmd2` 0.9.13 @@ -9,9 +10,9 @@ * We make no API stability guarantees about these internal functions * **Renamed Commands Notice** * The following commands have been renamed. The old names will be supported until the next release. - * load --> run_script - * _relative_load --> _relative_run_script - * pyscript --> run_pyscript + * `load` --> `run_script` + * `_relative_load` --> `_relative_run_script` + * `pyscript` --> `run_pyscript` ## 0.9.13 (June 14, 2019) * Bug Fixes 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 |