summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJared Crapo <jared@kotfu.net>2017-08-21 14:30:29 -0600
committerJared Crapo <jared@kotfu.net>2017-08-21 14:31:26 -0600
commit560133d0c95845e0b573d70303fc96d999c52c03 (patch)
treefbb1cac237e444a8b51a84509f2b75c3e95020b9 /tests
parent1f2fea6c481bdcba526bc10c29edd162cf5212c7 (diff)
downloadcmd2-git-560133d0c95845e0b573d70303fc96d999c52c03.tar.gz
Simple but working version of new regex transcript
Escapes of slashes don’t work yet.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_transcript.py22
1 files changed, 21 insertions, 1 deletions
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
+