diff options
author | kotfu <kotfu@kotfu.net> | 2018-05-24 19:02:32 -0600 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2018-05-24 19:02:32 -0600 |
commit | 190fecb34ac91e25f64615f378d6d59ef6d77de8 (patch) | |
tree | 3cfa590653af8b7570bd4073384467d2ca736fa0 /cmd2/transcript.py | |
parent | db881e13796abdaabe6cb7d4121389c36e9aa407 (diff) | |
download | cmd2-git-190fecb34ac91e25f64615f378d6d59ef6d77de8.tar.gz |
Make changes requested in PR #413
Diffstat (limited to 'cmd2/transcript.py')
-rw-r--r-- | cmd2/transcript.py | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/cmd2/transcript.py b/cmd2/transcript.py index 7cf15d7d..8a9837a6 100644 --- a/cmd2/transcript.py +++ b/cmd2/transcript.py @@ -1,5 +1,14 @@ # # -*- coding: utf-8 -*- +"""Machinery for running and validating transcripts. + +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() +""" import re import glob import unittest @@ -7,9 +16,14 @@ import unittest from . import utils class Cmd2TestCase(unittest.TestCase): - """Subclass this, setting CmdApp, to make a unittest.TestCase class - that will execute the commands in a transcript file and expect the results shown. - See example.py""" + """A unittest class used for transcript testing. + + Subclass this, setting CmdApp, to make a unittest.TestCase class + that will execute the commands in a transcript file and expect the + results shown. + + See example.py + """ cmdapp = None def fetchTranscripts(self): @@ -90,7 +104,7 @@ class Cmd2TestCase(unittest.TestCase): self.assertTrue(re.match(expected, result, re.MULTILINE | re.DOTALL), message) def _transform_transcript_expected(self, s): - """parse the string with slashed regexes into a valid regex + """Parse the string with slashed regexes into a valid regex. Given a string like: @@ -138,8 +152,7 @@ class Cmd2TestCase(unittest.TestCase): @staticmethod def _escaped_find(regex, s, start, in_regex): - """ - Find the next slash in {s} after {start} that is not preceded by a backslash. + """Find the next slash in {s} after {start} that is not preceded by a backslash. If we find an escaped slash, add everything up to and including it to regex, updating {start}. {start} therefore serves two purposes, tells us where to start @@ -191,7 +204,9 @@ class Cmd2TestCase(unittest.TestCase): self.cmdapp.stdout = self._orig_stdout class OutputTrap(object): - """Instantiate an OutputTrap to divert/capture ALL stdout output. For use in transcript testing.""" + """Instantiate an OutputTrap to divert/capture ALL stdout output. + For use in transcript testing. + """ def __init__(self): self.contents = '' |