Skip to content

Commit f2166d8

Browse files
committed
Updated CHANGELOG and slightly refactored/reorganized comments and code in transcript.py
1 parent dd6f6b1 commit f2166d8

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 0.9.14 (TBD, 2019)
22
* Enhancements
33
* Added support for and testing with Python 3.8, starting with 3.8 beta
4+
* Improved information displayed during transcript testing
45
* Breaking Changes
56
* 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`
67
* If you need to use Python 3.4, you should pin your requirements to use `cmd2` 0.9.13
@@ -9,9 +10,9 @@
910
* We make no API stability guarantees about these internal functions
1011
* **Renamed Commands Notice**
1112
* The following commands have been renamed. The old names will be supported until the next release.
12-
* load --> run_script
13-
* _relative_load --> _relative_run_script
14-
* pyscript --> run_pyscript
13+
* `load` --> `run_script`
14+
* `_relative_load` --> `_relative_run_script`
15+
* `pyscript` --> `run_pyscript`
1516

1617
## 0.9.13 (June 14, 2019)
1718
* Bug Fixes

cmd2/transcript.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
we need a mechanism to run each command in the transcript as
77
a unit test, comparing the expected output to the actual output.
88
9-
This file contains the classess necessary to make that work. These
10-
classes are used in cmd2.py::run_transcript_tests()
9+
This file contains the class necessary to make that work. This
10+
class is used in cmd2.py::run_transcript_tests()
1111
"""
1212
import re
1313
import unittest
@@ -27,27 +27,32 @@ class Cmd2TestCase(unittest.TestCase):
2727
"""
2828
cmdapp = None
2929

30-
def fetchTranscripts(self):
31-
self.transcripts = {}
32-
for fname in self.cmdapp.testfiles:
33-
tfile = open(fname)
34-
self.transcripts[fname] = iter(tfile.readlines())
35-
tfile.close()
36-
3730
def setUp(self):
3831
if self.cmdapp:
39-
self.fetchTranscripts()
32+
self._fetchTranscripts()
4033

4134
# Trap stdout
4235
self._orig_stdout = self.cmdapp.stdout
4336
self.cmdapp.stdout = utils.StdSim(self.cmdapp.stdout)
4437

38+
def tearDown(self):
39+
if self.cmdapp:
40+
# Restore stdout
41+
self.cmdapp.stdout = self._orig_stdout
42+
4543
def runTest(self): # was testall
4644
if self.cmdapp:
4745
its = sorted(self.transcripts.items())
4846
for (fname, transcript) in its:
4947
self._test_transcript(fname, transcript)
5048

49+
def _fetchTranscripts(self):
50+
self.transcripts = {}
51+
for fname in self.cmdapp.testfiles:
52+
tfile = open(fname)
53+
self.transcripts[fname] = iter(tfile.readlines())
54+
tfile.close()
55+
5156
def _test_transcript(self, fname: str, transcript):
5257
line_num = 0
5358
finished = False
@@ -205,8 +210,3 @@ def _escaped_find(regex: str, s: str, start: int, in_regex: bool) -> Tuple[str,
205210
# slash is not escaped, this is what we are looking for
206211
break
207212
return regex, pos, start
208-
209-
def tearDown(self):
210-
if self.cmdapp:
211-
# Restore stdout
212-
self.cmdapp.stdout = self._orig_stdout

0 commit comments

Comments
 (0)