From 560133d0c95845e0b573d70303fc96d999c52c03 Mon Sep 17 00:00:00 2001 From: Jared Crapo Date: Mon, 21 Aug 2017 14:30:29 -0600 Subject: Simple but working version of new regex transcript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Escapes of slashes don’t work yet. --- tests/test_transcript.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tests/test_transcript.py') diff --git a/tests/test_transcript.py b/tests/test_transcript.py index adc162b1..fef28c7b 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -15,7 +15,8 @@ import six # Used for sm.input: raw_input() for Python 2 or input() for Python 3 import six.moves as sm -from cmd2 import Cmd, make_option, options, Cmd2TestCase, set_use_arg_list, set_posix_shlex, set_strip_quotes +from cmd2 import (Cmd, make_option, options, Cmd2TestCase, set_use_arg_list, + set_posix_shlex, set_strip_quotes) from conftest import run_cmd, StdOut, normalize @@ -279,3 +280,22 @@ def test_transcript(request, capsys, filename, feedback_to_output): else: assert err == '' assert out == '' + + +@pytest.mark.parametrize('expected, transformed', [ + ( 'text with no slashes', 'text\ with\ no\ slashes'), + ( 'specials .*', 'specials\ \.\*'), + ( '/.*/', '.*'), + ( 'specials ^ and + /[0-9]+/', 'specials\ \^\ and\ \+\ [0-9]+'), + ( '/a{6}/ but not a{6} with /.*?/ more', 'a{6}\ but\ not\ a\{6\}\ with\ .*?\ more'), + ]) +def test_parse_transcript_expected(expected, transformed): + app = CmdLineApp() + + class TestMyAppCase(Cmd2TestCase): + cmdapp = app + + testcase = TestMyAppCase() + + assert testcase._transform_transcript_expected(expected) == transformed + -- cgit v1.2.1