diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conftest.py | 16 | ||||
-rw-r--r-- | tests/test_cmd2.py | 30 | ||||
-rw-r--r-- | tests/test_pyscript.py | 2 |
3 files changed, 25 insertions, 23 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index faf1847d..1295a633 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -36,18 +36,18 @@ edit history macro pyscript set shortcuts BASE_HELP_VERBOSE = """ Documented commands (type help <topic>): ================================================================================ -alias Manages aliases +alias Manage aliases edit Edit a file in a text editor help List available commands with "help" or detailed help with "help cmd" history View, run, edit, save, or clear previously entered commands -load Runs commands in script file that is encoded as either ASCII or UTF-8 text -macro Manages macros -py Invoke python command, shell, or script -pyscript Runs a python script file inside the console -quit Exits this application -set Sets a settable parameter or shows current settings of parameters +load Run commands in script file that is encoded as either ASCII or UTF-8 text +macro Manage macros +py Invoke python command or shell +pyscript Run a python script file inside the console +quit Exit this application +set Set a settable parameter or shows current settings of parameters shell Execute a command as if at the OS prompt -shortcuts Lists shortcuts available +shortcuts List shortcuts available """ # Help text for the history command diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index e07e6af3..d250af26 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -69,7 +69,7 @@ def test_base_argparse_help(base_app, capsys): assert out1 == out2 assert out1[0].startswith('Usage: set') assert out1[1] == '' - assert out1[2].startswith('Sets a settable parameter') + assert out1[2].startswith('Set a settable parameter') def test_base_invalid_option(base_app, capsys): run_cmd(base_app, 'set -z') @@ -476,7 +476,7 @@ def test_load_with_empty_args(base_app, capsys): out, err = capsys.readouterr() # The load command requires a file path argument, so we should get an error message - assert "load command requires a file path" in str(err) + assert "the following arguments are required" in str(err) assert base_app.cmdqueue == [] @@ -862,7 +862,8 @@ def test_edit_file(base_app, request, monkeypatch): run_cmd(base_app, 'edit {}'.format(filename)) # We think we have an editor, so should expect a system call - m.assert_called_once_with('"{}" "{}"'.format(base_app.editor, filename)) + m.assert_called_once_with('{} {}'.format(utils.quote_string_if_needed(base_app.editor), + utils.quote_string_if_needed(filename))) def test_edit_file_with_spaces(base_app, request, monkeypatch): # Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock @@ -878,7 +879,8 @@ def test_edit_file_with_spaces(base_app, request, monkeypatch): run_cmd(base_app, 'edit "{}"'.format(filename)) # We think we have an editor, so should expect a system call - m.assert_called_once_with('"{}" "{}"'.format(base_app.editor, filename)) + m.assert_called_once_with('{} {}'.format(utils.quote_string_if_needed(base_app.editor), + utils.quote_string_if_needed(filename))) def test_edit_blank(base_app, monkeypatch): # Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock @@ -1253,17 +1255,17 @@ diddly This command does diddly Other ================================================================================ -alias Manages aliases +alias Manage aliases help List available commands with "help" or detailed help with "help cmd" history View, run, edit, save, or clear previously entered commands -load Runs commands in script file that is encoded as either ASCII or UTF-8 text -macro Manages macros -py Invoke python command, shell, or script -pyscript Runs a python script file inside the console -quit Exits this application -set Sets a settable parameter or shows current settings of parameters +load Run commands in script file that is encoded as either ASCII or UTF-8 text +macro Manage macros +py Invoke python command or shell +pyscript Run a python script file inside the console +quit Exit this application +set Set a settable parameter or shows current settings of parameters shell Execute a command as if at the OS prompt -shortcuts Lists shortcuts available +shortcuts List shortcuts available Undocumented commands: ====================== @@ -1560,7 +1562,7 @@ def test_is_text_file_bad_input(base_app): def test_eof(base_app): # Only thing to verify is that it returns True - assert base_app.do_eof('dont care') + assert base_app.do_eof('') def test_eos(base_app): sdir = 'dummy_dir' @@ -1568,7 +1570,7 @@ def test_eos(base_app): assert len(base_app._script_dir) == 1 # Assert that it does NOT return true - assert not base_app.do_eos('dont care') + assert not base_app.do_eos('') # And make sure it reduced the length of the script dir list assert len(base_app._script_dir) == 0 diff --git a/tests/test_pyscript.py b/tests/test_pyscript.py index 84abc965..c7769c7a 100644 --- a/tests/test_pyscript.py +++ b/tests/test_pyscript.py @@ -84,7 +84,7 @@ class PyscriptExample(Cmd): @with_argparser(foo_parser) def do_foo(self, args): - self.poutput('foo ' + str(args.__dict__)) + self.poutput('foo ' + str(sorted(args.__dict__))) if self._in_py: FooResult = namedtuple_with_defaults('FooResult', ['counter', 'trueval', 'constval', |