summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-03-13 23:33:58 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2019-03-13 23:33:58 -0400
commit88b45e12b0c2c9e7f8e386504f2d6808f396560b (patch)
tree66209a092dc11528f73a9cb1a991c620be09a815 /tests
parent23fad46d5187600d52b95125bb1629e491cb9e6f (diff)
downloadcmd2-git-88b45e12b0c2c9e7f8e386504f2d6808f396560b.tar.gz
First stage of attribute refactoring
The following are now arguments to cmd2.Cmd.__init__() instead of class attributes: * allow_redirection * multiline_commands * terminators * shortcuts Added a couple read-only properties for convenience of cmd2.Cmd accessing immutable members from self.statement_parser
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cmd2.py9
-rw-r--r--tests/test_completion.py6
-rw-r--r--tests/test_transcript.py3
3 files changed, 8 insertions, 10 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index b3942203..368ca221 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -105,7 +105,7 @@ def test_base_show_readonly(base_app):
Commands may be terminated with: {}
Arguments at invocation allowed: {}
Output redirection and pipes allowed: {}
-""".format(base_app.terminators, base_app.allow_cli_args, base_app.allow_redirection))
+""".format(base_app.statement_parser.terminators, base_app.allow_cli_args, base_app.allow_redirection))
assert out == expected
@@ -557,9 +557,9 @@ def test_feedback_to_output_false(base_app, capsys):
os.remove(filename)
-def test_allow_redirection(base_app):
+def test_disallow_redirection(base_app):
# Set allow_redirection to False
- base_app.allow_redirection = False
+ base_app.statement_parser.allow_redirection = False
filename = 'test_allow_redirect.txt'
@@ -1264,8 +1264,7 @@ def test_which_editor_bad():
class MultilineApp(cmd2.Cmd):
def __init__(self, *args, **kwargs):
- self.multiline_commands = ['orate']
- super().__init__(*args, **kwargs)
+ super().__init__(*args, multiline_commands=['orate'], **kwargs)
orate_parser = argparse.ArgumentParser()
orate_parser.add_argument('-s', '--shout', action="store_true", help="N00B EMULATION MODE")
diff --git a/tests/test_completion.py b/tests/test_completion.py
index da7fae65..a7c26928 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -635,7 +635,7 @@ def test_tokens_for_completion_redirect(cmd2_app):
endidx = len(line)
begidx = endidx - len(text)
- cmd2_app.allow_redirection = True
+ cmd2_app.statement_parser.allow_redirection = True
expected_tokens = ['command', '|', '<', '>>', 'file']
expected_raw_tokens = ['command', '|', '<', '>>', 'file']
@@ -649,7 +649,7 @@ def test_tokens_for_completion_quoted_redirect(cmd2_app):
endidx = len(line)
begidx = endidx - len(text)
- cmd2_app.allow_redirection = True
+ cmd2_app.statement_parser.redirection = True
expected_tokens = ['command', '>file']
expected_raw_tokens = ['command', '">file']
@@ -663,7 +663,7 @@ def test_tokens_for_completion_redirect_off(cmd2_app):
endidx = len(line)
begidx = endidx - len(text)
- cmd2_app.allow_redirection = False
+ cmd2_app.statement_parser.allow_redirection = False
expected_tokens = ['command', '>file']
expected_raw_tokens = ['command', '>file']
diff --git a/tests/test_transcript.py b/tests/test_transcript.py
index f93642b8..4a03ebe0 100644
--- a/tests/test_transcript.py
+++ b/tests/test_transcript.py
@@ -29,10 +29,9 @@ class CmdLineApp(cmd2.Cmd):
MUMBLE_LAST = ['right?']
def __init__(self, *args, **kwargs):
- self.multiline_commands = ['orate']
self.maxrepeats = 3
- super().__init__(*args, **kwargs)
+ super().__init__(*args, multiline_commands=['orate'], **kwargs)
# Make maxrepeats settable at runtime
self.settable['maxrepeats'] = 'Max number of `--repeat`s allowed'