diff options
Diffstat (limited to 'docs/freefeatures.rst')
-rw-r--r-- | docs/freefeatures.rst | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/docs/freefeatures.rst b/docs/freefeatures.rst index 7b6762ad..efb74316 100644 --- a/docs/freefeatures.rst +++ b/docs/freefeatures.rst @@ -82,6 +82,8 @@ quotation marks if it is more than a one-word command. .. _Argparse: https://docs.python.org/3/library/argparse.html +.. _output_redirection: + Output redirection ================== @@ -301,34 +303,20 @@ is equivalent to ``shell ls``.) Transcript-based testing ======================== -If the entire transcript (input and output) of a successful session of -a ``cmd2``-based app is copied from the screen and pasted into a text -file, ``transcript.txt``, then a transcript test can be run against it:: - - python app.py --test transcript.txt +A transcript is both the input and output of a successful session of a +``cmd2``-based app which is saved to a text file. The transcript can be played +back into the app as a unit test. -Any non-whitespace deviations between the output prescribed in ``transcript.txt`` and -the actual output from a fresh run of the application will be reported -as a unit test failure. (Whitespace is ignored during the comparison.) +.. code-block:: none -Regular expressions can be embedded in the transcript inside paired ``/`` -slashes. These regular expressions should not include any whitespace -expressions. - -.. note:: + $ python example.py --test transcript_regex.txt + . + ---------------------------------------------------------------------- + Ran 1 test in 0.013s - If you have set ``allow_cli_args`` to False in order to disable parsing of command line arguments at invocation, - then the use of ``-t`` or ``--test`` to run transcript testing is automatically disabled. In this case, you can - alternatively provide a value for the optional ``transcript_files`` when constructing the instance of your - ``cmd2.Cmd`` derived class in order to cause a transcript test to run:: - - from cmd2 import Cmd - class App(Cmd): - # customized attributes and methods here + OK - if __name__ == '__main__': - app = App(transcript_files=['exampleSession.txt']) - app.cmdloop() +See :doc:`transcript` for more details. Tab-Completion |