summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-04 19:25:02 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-04 19:25:02 -0500
commit4bec7b5f7861d0a7e12a6abf32004b5ffaf565ee (patch)
treea7100fa8669449c754cf8c6f235b4bbeeb467464
parent4ad08851a03171c747d7f071355ec7ad64bc1e78 (diff)
downloadcmd2-git-4bec7b5f7861d0a7e12a6abf32004b5ffaf565ee.tar.gz
Added unit test for "show -l".
-rw-r--r--tests/conftest.py16
-rw-r--r--tests/test_cmd2.py14
2 files changed, 27 insertions, 3 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 64cdfd2e..a2f79579 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -57,6 +57,7 @@ continuation_prompt: >
debug: False
default_file_name: command.txt
echo: False
+editor: vim
feedback_to_output: False
prompt: (Cmd)
quiet: False
@@ -64,6 +65,21 @@ timing: False
""".format(expect_colors)
+SHOW_LONG = """abbrev: True # Accept abbreviated commands
+case_insensitive: True # upper- and lower-case both OK
+colors: True # 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: False # include nonessentials in `|`, `>` results
+prompt: (Cmd) #
+quiet: False # Don't print nonessential feedback
+timing: False # Report execution times
+"""
+
+
class StdOut(object):
""" Toy class for replacing self.stdout in cmd2.Cmd instances fror unit testing. """
def __init__(self):
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index bb1f7d09..0806bee3 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -13,7 +13,7 @@ import pytest
import six
import cmd2
-from conftest import run_cmd, normalize, BASE_HELP, HELP_HISTORY, SHORTCUTS_TXT, SHOW_TXT
+from conftest import run_cmd, normalize, BASE_HELP, HELP_HISTORY, SHORTCUTS_TXT, SHOW_TXT, SHOW_LONG
def test_ver():
@@ -39,10 +39,18 @@ def test_base_shortcuts(base_app):
def test_base_show(base_app):
+ # force editor to be 'vim' so test is repeatable across platforms
+ base_app.editor = 'vim'
out = run_cmd(base_app, 'show')
expected = normalize(SHOW_TXT)
- # ignore "editor: vi" (could be others)
- out = [l for l in out if not l.startswith('editor: ')]
+ assert out == expected
+
+
+def test_base_show_long(base_app):
+ # force editor to be 'vim' so test is repeatable across platforms
+ base_app.editor = 'vim'
+ out = run_cmd(base_app, 'show -l')
+ expected = normalize(SHOW_LONG)
assert out == expected