summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-01-16 21:17:21 -0700
committerkotfu <kotfu@kotfu.net>2018-01-16 21:17:21 -0700
commitfd5750fbcc19ab719d803e6d8355633523ae2842 (patch)
treef1341d0c514812610491ba9107eab2dc562acff4 /tests
parentd8ade122f0cd23dfcad18872536cc3709334e77f (diff)
downloadcmd2-git-fd5750fbcc19ab719d803e6d8355633523ae2842.tar.gz
do_edit() no longer edits history, just files #252
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py2
-rw-r--r--tests/test_cmd2.py73
-rw-r--r--tests/transcripts/regex_set.txt1
3 files changed, 0 insertions, 76 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 89a3bbf8..387322b1 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -53,7 +53,6 @@ if sys.platform.startswith('win'):
expect_colors = False
# Output from the show command with default settings
SHOW_TXT = """abbrev: False
-autorun_on_edit: False
colors: {}
continuation_prompt: >
debug: False
@@ -72,7 +71,6 @@ else:
color_str = 'False'
SHOW_LONG = """
abbrev: False # Accept abbreviated commands
-autorun_on_edit: False # Automatically run files after editing
colors: {} # Colorized output (*nix only)
continuation_prompt: > # On 2nd+ line of input
debug: False # Show full error stack on error
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 8ee41096..86296246 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -780,84 +780,11 @@ def test_edit_blank(base_app, monkeypatch):
m = mock.MagicMock(name='system')
monkeypatch.setattr("os.system", m)
- # Run help command just so we have a command in history
- run_cmd(base_app, 'help')
-
- run_cmd(base_app, 'edit')
-
- # We have an editor, so should expect a system call
- m.assert_called_once()
-
-def test_edit_empty_history(base_app, capsys):
run_cmd(base_app, 'edit')
- out, err = capsys.readouterr()
- assert out == ''
- assert err == 'ERROR: edit must be called with argument if history is empty\n'
-
-def test_edit_valid_positive_number(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
- base_app.editor = 'fooedit'
-
- # Mock out the os.system call so we don't actually open an editor
- m = mock.MagicMock(name='system')
- monkeypatch.setattr("os.system", m)
-
- # Run help command just so we have a command in history
- run_cmd(base_app, 'help')
-
- run_cmd(base_app, 'edit 1')
# We have an editor, so should expect a system call
m.assert_called_once()
-def test_edit_valid_negative_number(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
- base_app.editor = 'fooedit'
-
- # Mock out the os.system call so we don't actually open an editor
- m = mock.MagicMock(name='system')
- monkeypatch.setattr("os.system", m)
-
- # Run help command just so we have a command in history
- run_cmd(base_app, 'help')
-
- run_cmd(base_app, 'edit "-1"')
-
- # We have an editor, so should expect a system call
- m.assert_called_once()
-
-def test_edit_invalid_positive_number(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
- base_app.editor = 'fooedit'
-
- # Mock out the os.system call so we don't actually open an editor
- m = mock.MagicMock(name='system')
- monkeypatch.setattr("os.system", m)
-
- # Run help command just so we have a command in history
- run_cmd(base_app, 'help')
-
- run_cmd(base_app, 'edit 23')
-
- # History index is invalid, so should expect a system call
- m.assert_not_called()
-
-def test_edit_invalid_negative_number(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
- base_app.editor = 'fooedit'
-
- # Mock out the os.system call so we don't actually open an editor
- m = mock.MagicMock(name='system')
- monkeypatch.setattr("os.system", m)
-
- # Run help command just so we have a command in history
- run_cmd(base_app, 'help')
-
- run_cmd(base_app, 'edit "-23"')
-
- # History index is invalid, so should expect a system call
- m.assert_not_called()
-
def test_base_py_interactive(base_app):
# Mock out the InteractiveConsole.interact() call so we don't actually wait for a user's response on stdin
diff --git a/tests/transcripts/regex_set.txt b/tests/transcripts/regex_set.txt
index 3a4a234d..6c12b4cb 100644
--- a/tests/transcripts/regex_set.txt
+++ b/tests/transcripts/regex_set.txt
@@ -5,7 +5,6 @@
(Cmd) set
abbrev: True
-autorun_on_edit: False
colors: /(True|False)/
continuation_prompt: >/ /
debug: False