diff options
| author | Todd Leonhardt <tleonhardt@gmail.com> | 2017-06-28 17:57:23 -0400 |
|---|---|---|
| committer | Todd Leonhardt <tleonhardt@gmail.com> | 2017-06-28 17:57:23 -0400 |
| commit | 9efa8ee8d0e14d494eb954cd356d17832573deee (patch) | |
| tree | 057bc6f5fbb101ce3b4d0c5b68edebd8735eaae1 /tests | |
| parent | 38f509964141530a246effb87c0d3ed30e6918b1 (diff) | |
| download | cmd2-git-9efa8ee8d0e14d494eb954cd356d17832573deee.tar.gz | |
Completely removed use of self.default_file_name
Load and relative load now require a file path
Edit will use a temporary file by default and delete it when done
Save will use a temporary file by default and inform the user what it is
Also changed the default value for autorun_on_edit to False so that it can safely be used as an actual file editor.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/conftest.py | 31 | ||||
| -rw-r--r-- | tests/test_cmd2.py | 10 | ||||
| -rw-r--r-- | tests/test_completion.py | 2 | ||||
| -rw-r--r-- | tests/transcript_regex.txt | 3 |
4 files changed, 19 insertions, 27 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 77f525f7..6941d9fc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -48,12 +48,11 @@ if sys.platform.startswith('win'): expect_colors = False # Output from the show command with default settings SHOW_TXT = """abbrev: True -autorun_on_edit: True +autorun_on_edit: False case_insensitive: True colors: {} continuation_prompt: > debug: False -default_file_name: command.txt echo: False editor: vim feedback_to_output: True @@ -67,20 +66,20 @@ if expect_colors: color_str = 'True ' else: color_str = 'False' -SHOW_LONG = """abbrev: True # Accept abbreviated commands -autorun_on_edit: True # Automatically run files after editing -case_insensitive: True # upper- and lower-case both OK -colors: {} # Colorized output (*nix only) -continuation_prompt: > # On 2nd+ line of input -debug: False # Show full error stack on error -default_file_name: command.txt # for ``save``, ``load``, etc. -echo: False # Echo command issued into output -editor: vim # Program used by ``edit`` -feedback_to_output: True # include nonessentials in `|`, `>` results -locals_in_py: True # Allow access to your application in py via self -prompt: (Cmd) # The prompt issued to solicit input -quiet: False # Don't print nonessential feedback -timing: False # Report execution times +SHOW_LONG = """ +abbrev: True # Accept abbreviated commands +autorun_on_edit: False # Automatically run files after editing +case_insensitive: True # Upper- and lower-case both OK +colors: {} # Colorized output (*nix only) +continuation_prompt: > # On 2nd+ line of input +debug: False # Show full error stack on error +echo: False # Echo command issued into output +editor: vim # Program used by ``edit`` +feedback_to_output: True # Include nonessentials in `|`, `>` results +locals_in_py: True # Allow access to your application in py via self +prompt: (Cmd) # The prompt issued to solicit input +quiet: False # Don't print nonessential feedback +timing: False # Report execution times """.format(color_str) diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 92fdaa14..707699f3 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -545,10 +545,7 @@ def test_edit_number(base_app): run_cmd(base_app, 'edit 1') # We have an editor, so should expect a system call - m.assert_called_once_with('{} {}'.format(base_app.editor, base_app.default_file_name)) - - # Editing history item causes a file of default name to get created, remove it so we have a clean slate - os.remove(base_app.default_file_name) + m.assert_called_once() def test_edit_blank(base_app): @@ -565,10 +562,7 @@ def test_edit_blank(base_app): run_cmd(base_app, 'edit') # We have an editor, so should expect a system call - m.assert_called_once_with('{} {}'.format(base_app.editor, base_app.default_file_name)) - - # Editing history item causes a file of default name to get created, remove it so we have a clean slate - os.remove(base_app.default_file_name) + m.assert_called_once() def test_base_py_interactive(base_app): diff --git a/tests/test_completion.py b/tests/test_completion.py index 74cc3d57..220d6e26 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -150,7 +150,7 @@ def test_path_completion_multiple(cmd2_app, request): endidx = len(line) begidx = endidx - len(text) - assert cmd2_app.path_complete(text, line, begidx, endidx) == ['script.py', 'script.txt'] + assert cmd2_app.path_complete(text, line, begidx, endidx) == ['script.py', 'script.txt', 'scripts/'] def test_path_completion_nomatch(cmd2_app, request): test_dir = os.path.dirname(request.module.__file__) diff --git a/tests/transcript_regex.txt b/tests/transcript_regex.txt index a44870e9..4cddad2c 100644 --- a/tests/transcript_regex.txt +++ b/tests/transcript_regex.txt @@ -2,12 +2,11 @@ # The regex for editor matches any word until first space. The one for colors is because no color on Windows. (Cmd) set abbrev: True -autorun_on_edit: True +autorun_on_edit: False case_insensitive: True colors: /(True|False)/ continuation_prompt: > debug: False -default_file_name: command.txt echo: False editor: /([^\s]+)/ feedback_to_output: True |
