summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py2
-rw-r--r--tests/test_argparse.py2
-rw-r--r--tests/test_cmd2.py20
-rw-r--r--tests/test_completion.py2
-rw-r--r--tests/test_parsing.py18
-rw-r--r--tests/test_submenu.py2
-rw-r--r--tests/test_transcript.py8
7 files changed, 26 insertions, 28 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index ed76cba9..0a42d833 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -10,7 +10,7 @@ import sys
from pytest import fixture
from unittest import mock
-import cmd2
+from cmd2 import cmd2
# Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit)
try:
diff --git a/tests/test_argparse.py b/tests/test_argparse.py
index 6a9a93a7..e23c5d17 100644
--- a/tests/test_argparse.py
+++ b/tests/test_argparse.py
@@ -5,7 +5,7 @@ Cmd2 testing for argument parsing
import argparse
import pytest
-import cmd2
+from cmd2 import cmd2
from unittest import mock
from .conftest import run_cmd, StdOut
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 48f50bdc..c8955497 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -21,7 +21,7 @@ try:
except ImportError:
from unittest import mock
-import cmd2
+from cmd2 import cmd2
from .conftest import run_cmd, normalize, BASE_HELP, BASE_HELP_VERBOSE, \
HELP_HISTORY, SHORTCUTS_TXT, SHOW_TXT, SHOW_LONG, StdOut
@@ -109,8 +109,8 @@ def test_base_show_readonly(base_app):
Strip Quotes after splitting arguments: {}
""".format(base_app.terminators, base_app.allow_cli_args, base_app.allow_redirection,
- "POSIX" if cmd2.cmd2.POSIX_SHLEX else "non-POSIX",
- "True" if cmd2.cmd2.STRIP_QUOTES_FOR_NON_POSIX and not cmd2.cmd2.POSIX_SHLEX else "False"))
+ "POSIX" if cmd2.POSIX_SHLEX else "non-POSIX",
+ "True" if cmd2.STRIP_QUOTES_FOR_NON_POSIX and not cmd2.POSIX_SHLEX else "False"))
assert out == expected
@@ -647,18 +647,18 @@ def test_pipe_to_shell_error(base_app, capsys):
assert err.startswith("EXCEPTION of type '{}' occurred with message:".format(expected_error))
-@pytest.mark.skipif(not cmd2.cmd2.can_clip,
+@pytest.mark.skipif(not cmd2.can_clip,
reason="Pyperclip could not find a copy/paste mechanism for your system")
def test_send_to_paste_buffer(base_app):
# Test writing to the PasteBuffer/Clipboard
run_cmd(base_app, 'help >')
expected = normalize(BASE_HELP)
- assert normalize(cmd2.cmd2.get_paste_buffer()) == expected
+ assert normalize(cmd2.get_paste_buffer()) == expected
# Test appending to the PasteBuffer/Clipboard
run_cmd(base_app, 'help history >>')
expected = normalize(BASE_HELP + '\n' + HELP_HISTORY)
- assert normalize(cmd2.cmd2.get_paste_buffer()) == expected
+ assert normalize(cmd2.get_paste_buffer()) == expected
def test_base_timing(base_app, capsys):
@@ -1314,7 +1314,7 @@ optional arguments:
reason="cmd2._which function only used on Mac and Linux")
def test_which_editor_good():
editor = 'vi'
- path = cmd2.cmd2._which(editor)
+ path = cmd2._which(editor)
# Assert that the vi editor was found because it should exist on all Mac and Linux systems
assert path
@@ -1322,7 +1322,7 @@ def test_which_editor_good():
reason="cmd2._which function only used on Mac and Linux")
def test_which_editor_bad():
editor = 'notepad.exe'
- path = cmd2.cmd2._which(editor)
+ path = cmd2._which(editor)
# Assert that the editor wasn't found because no notepad.exe on non-Windows systems ;-)
assert path is None
@@ -1349,7 +1349,7 @@ def multiline_app():
return app
def test_multiline_complete_empty_statement_raises_exception(multiline_app):
- with pytest.raises(cmd2.cmd2.EmptyStatement):
+ with pytest.raises(cmd2.EmptyStatement):
multiline_app._complete_statement('')
def test_multiline_complete_statement_without_terminator(multiline_app):
@@ -1367,7 +1367,7 @@ def test_multiline_complete_statement_without_terminator(multiline_app):
def test_clipboard_failure(capsys):
# Force cmd2 clipboard to be disabled
- cmd2.cmd2.disable_clip()
+ cmd2.disable_clip()
app = cmd2.Cmd()
# Redirect command output to the clipboard when a clipboard isn't present
diff --git a/tests/test_completion.py b/tests/test_completion.py
index cf45f281..2c600018 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -12,7 +12,7 @@ import argparse
import os
import sys
-import cmd2
+from cmd2 import cmd2
import pytest
from .conftest import complete_tester, StdOut
from examples.subcommands import SubcommandsExample
diff --git a/tests/test_parsing.py b/tests/test_parsing.py
index 2682ec68..b61e2d06 100644
--- a/tests/test_parsing.py
+++ b/tests/test_parsing.py
@@ -8,16 +8,14 @@ problematic because they worked properly for some versions of pyparsing but not
Copyright 2017 Todd Leonhardt <todd.leonhardt@gmail.com>
Released under MIT license, see LICENSE file
"""
-import sys
-
-import cmd2
+from cmd2 import cmd2
import pytest
@pytest.fixture
def hist():
from cmd2.cmd2 import HistoryItem
- h = cmd2.cmd2.History([HistoryItem('first'), HistoryItem('second'), HistoryItem('third'), HistoryItem('fourth')])
+ h = cmd2.History([HistoryItem('first'), HistoryItem('second'), HistoryItem('third'), HistoryItem('fourth')])
return h
# Case-sensitive parser
@@ -25,7 +23,7 @@ def hist():
def parser():
c = cmd2.Cmd()
c.multilineCommands = ['multiline']
- c.parser_manager = cmd2.cmd2.ParserManager(redirector=c.redirector, terminators=c.terminators,
+ c.parser_manager = cmd2.ParserManager(redirector=c.redirector, terminators=c.terminators,
multilineCommands=c.multilineCommands, legalChars=c.legalChars,
commentGrammars=c.commentGrammars, commentInProgress=c.commentInProgress,
blankLinesAllowed=c.blankLinesAllowed, prefixParser=c.prefixParser,
@@ -38,7 +36,7 @@ def parser():
def cs_pm():
c = cmd2.Cmd()
c.multilineCommands = ['multiline']
- c.parser_manager = cmd2.cmd2.ParserManager(redirector=c.redirector, terminators=c.terminators,
+ c.parser_manager = cmd2.ParserManager(redirector=c.redirector, terminators=c.terminators,
multilineCommands=c.multilineCommands, legalChars=c.legalChars,
commentGrammars=c.commentGrammars, commentInProgress=c.commentInProgress,
blankLinesAllowed=c.blankLinesAllowed, prefixParser=c.prefixParser,
@@ -77,7 +75,7 @@ def test_history_get(hist):
def test_cast():
- cast = cmd2.cmd2.cast
+ cast = cmd2.cast
# Boolean
assert cast(True, True) == True
@@ -101,7 +99,7 @@ def test_cast():
def test_cast_problems(capsys):
- cast = cmd2.cmd2.cast
+ cast = cmd2.cast
expected = 'Problem setting parameter (now {}) to {}; incorrect type?\n'
@@ -327,8 +325,8 @@ def test_parse_input_redirect_from_unicode_filename(input_parser):
def test_empty_statement_raises_exception():
app = cmd2.Cmd()
- with pytest.raises(cmd2.cmd2.EmptyStatement):
+ with pytest.raises(cmd2.EmptyStatement):
app._complete_statement('')
- with pytest.raises(cmd2.cmd2.EmptyStatement):
+ with pytest.raises(cmd2.EmptyStatement):
app._complete_statement(' ')
diff --git a/tests/test_submenu.py b/tests/test_submenu.py
index fbb9857b..db334daa 100644
--- a/tests/test_submenu.py
+++ b/tests/test_submenu.py
@@ -4,7 +4,7 @@ Cmd2 testing for argument parsing
"""
import pytest
-import cmd2
+from cmd2 import cmd2
from .conftest import run_cmd, StdOut, normalize
diff --git a/tests/test_transcript.py b/tests/test_transcript.py
index 8ee5f3f6..4f821c06 100644
--- a/tests/test_transcript.py
+++ b/tests/test_transcript.py
@@ -14,8 +14,8 @@ import random
from unittest import mock
import pytest
-import cmd2
-from cmd2 import set_posix_shlex, set_strip_quotes
+from cmd2 import cmd2
+from cmd2.cmd2 import set_posix_shlex, set_strip_quotes
from .conftest import run_cmd, StdOut, normalize
class CmdLineApp(cmd2.Cmd):
@@ -189,7 +189,7 @@ now: --->
assert out == expected
-class TestMyAppCase(cmd2.cmd2.Cmd2TestCase):
+class TestMyAppCase(cmd2.Cmd2TestCase):
CmdApp = CmdLineApp
CmdApp.testfiles = ['tests/transcript.txt']
@@ -293,7 +293,7 @@ def test_transcript(request, capsys, filename, feedback_to_output):
def test_parse_transcript_expected(expected, transformed):
app = CmdLineApp()
- class TestMyAppCase(cmd2.cmd2.Cmd2TestCase):
+ class TestMyAppCase(cmd2.Cmd2TestCase):
cmdapp = app
testcase = TestMyAppCase()