summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-06-28 19:05:25 -0400
committerGitHub <noreply@github.com>2017-06-28 19:05:25 -0400
commit63c17bbefdea43a7839b333eb2af44e12bdde53f (patch)
treeea8632f40502947d34c3d14d20c6d64a470ea712 /tests
parent28b5a6b8667f2e105c6c38ef9cf341a0087006fb (diff)
parentf5224cf0af76c639007763c351d1b9fa02ee1208 (diff)
downloadcmd2-git-63c17bbefdea43a7839b333eb2af44e12bdde53f.tar.gz
Merge pull request #143 from python-cmd2/no_url_load
Refactored to remove a few things that felt out of place
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py31
-rw-r--r--tests/relative_multiple.txt1
-rw-r--r--tests/script.txt1
-rw-r--r--tests/scripts/one_down.txt1
-rw-r--r--tests/test_cmd2.py21
-rw-r--r--tests/test_completion.py2
-rw-r--r--tests/transcript_regex.txt3
7 files changed, 24 insertions, 36 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/relative_multiple.txt b/tests/relative_multiple.txt
new file mode 100644
index 00000000..bbd11739
--- /dev/null
+++ b/tests/relative_multiple.txt
@@ -0,0 +1 @@
+_relative_load scripts/one_down.txt
diff --git a/tests/script.txt b/tests/script.txt
index 1e18262a..4dfe9677 100644
--- a/tests/script.txt
+++ b/tests/script.txt
@@ -1,2 +1 @@
-help
help history
diff --git a/tests/scripts/one_down.txt b/tests/scripts/one_down.txt
new file mode 100644
index 00000000..b87ff844
--- /dev/null
+++ b/tests/scripts/one_down.txt
@@ -0,0 +1 @@
+_relative_load ../script.txt
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 4fd9ca1c..5ca95275 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -283,18 +283,13 @@ load {}
assert out == expected
-def test_base_load_default_file(base_app, capsys):
- # TODO: Make sure to remove the 'command.txt' file in case it exists
-
+def test_base_load_with_empty_args(base_app, capsys):
# The way the load command works, we can't directly capture its stdout or stderr
run_cmd(base_app, 'load')
out, err = capsys.readouterr()
- # The default file 'command.txt' doesn't exist, so we should get an error message
- expected = normalize("""ERROR: Problem accessing script from command.txt:
-[Errno 2] No such file or directory: 'command.txt.txt'
-To enable full traceback, run the following command: 'set debug true'
-""")
+ # The load command requires a file path argument, so we should get an error message
+ expected = normalize("""ERROR: load command requires a file path:\n""")
assert normalize(str(err)) == expected
@@ -550,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):
@@ -570,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..a12a4ec2 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' + os.path.sep]
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