summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-04-15 14:26:29 -0700
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-04-15 14:26:29 -0700
commit60dddb03d05ccf4088242a524e624f61782dd40f (patch)
tree816eb6176ea40bf9d7c6f0d15715fe0a4b813cda /tests/test_cmd2.py
parent40eb6f6c9428a5a3a54cebef34da7dae173dd074 (diff)
downloadcmd2-git-60dddb03d05ccf4088242a524e624f61782dd40f.tar.gz
Started removing dependency on six
Removed all dependency on six other than for six.moves.input Also: - Started removing code branches which were for Python 2 support
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r--tests/test_cmd2.py38
1 files changed, 10 insertions, 28 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 04498c49..9f0b13ee 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -145,10 +145,7 @@ now: True
def test_base_shell(base_app, monkeypatch):
m = mock.Mock()
- subprocess = 'subprocess'
- if six.PY2:
- subprocess = 'subprocess32'
- monkeypatch.setattr("{}.Popen".format(subprocess), m)
+ monkeypatch.setattr("{}.Popen".format('subprocess'), m)
out = run_cmd(base_app, 'shell echo a')
assert out == []
assert m.called
@@ -642,15 +639,8 @@ def test_pipe_to_shell_error(base_app, capsys):
# Try to pipe command output to a shell command that doesn't exist in order to produce an error
run_cmd(base_app, 'help | foobarbaz.this_does_not_exist')
out, err = capsys.readouterr()
-
assert not out
-
expected_error = 'FileNotFoundError'
- if six.PY2:
- if sys.platform.startswith('win'):
- expected_error = 'WindowsError'
- else:
- expected_error = 'OSError'
assert err.startswith("EXCEPTION of type '{}' occurred with message:".format(expected_error))
@@ -719,8 +709,8 @@ def test_base_colorize(base_app):
def _expected_no_editor_error():
expected_exception = 'OSError'
- # If using Python 2 or PyPy (either 2 or 3), expect a different exception than with Python 3
- if six.PY2 or hasattr(sys, "pypy_translation_info"):
+ # If PyPy, expect a different exception than with Python 3
+ if hasattr(sys, "pypy_translation_info"):
expected_exception = 'EnvironmentError'
expected_text = normalize("""
@@ -885,8 +875,7 @@ def test_cmdloop_without_rawinput():
class HookFailureApp(cmd2.Cmd):
def __init__(self, *args, **kwargs):
- # Need to use this older form of invoking super class constructor to support Python 2.x and Python 3.x
- cmd2.Cmd.__init__(self, *args, **kwargs)
+ super().__init__(*args, **kwargs)
def postparsing_precmd(self, statement):
"""Simulate precmd hook failure."""
@@ -910,8 +899,7 @@ def test_precmd_hook_failure(hook_failure):
class SayApp(cmd2.Cmd):
def __init__(self, *args, **kwargs):
- # Need to use this older form of invoking super class constructor to support Python 2.x and Python 3.x
- cmd2.Cmd.__init__(self, *args, **kwargs)
+ super().__init__(*args, **kwargs)
def do_say(self, arg):
self.poutput(arg)
@@ -953,8 +941,7 @@ def test_interrupt_noquit(say_app):
class ShellApp(cmd2.Cmd):
def __init__(self, *args, **kwargs):
- # Need to use this older form of invoking super class constructor to support Python 2.x and Python 3.x
- cmd2.Cmd.__init__(self, *args, **kwargs)
+ super().__init__(*args, **kwargs)
self.default_to_shell = True
@pytest.fixture
@@ -1020,8 +1007,7 @@ def test_ansi_prompt_escaped():
class HelpApp(cmd2.Cmd):
"""Class for testing custom help_* methods which override docstring help."""
def __init__(self, *args, **kwargs):
- # Need to use this older form of invoking super class constructor to support Python 2.x and Python 3.x
- cmd2.Cmd.__init__(self, *args, **kwargs)
+ super().__init__(*args, **kwargs)
def do_squat(self, arg):
"""This docstring help will never be shown because the help_squat method overrides it."""
@@ -1077,8 +1063,7 @@ def test_help_overridden_method(help_app):
class HelpCategoriesApp(cmd2.Cmd):
"""Class for testing custom help_* methods which override docstring help."""
def __init__(self, *args, **kwargs):
- # Need to use this older form of invoking super class constructor to support Python 2.x and Python 3.x
- cmd2.Cmd.__init__(self, *args, **kwargs)
+ super().__init__(*args, **kwargs)
@cmd2.with_category('Some Category')
def do_diddly(self, arg):
@@ -1342,9 +1327,7 @@ def test_which_editor_bad():
class MultilineApp(cmd2.Cmd):
def __init__(self, *args, **kwargs):
self.multilineCommands = ['orate']
-
- # Need to use this older form of invoking super class constructor to support Python 2.x and Python 3.x
- cmd2.Cmd.__init__(self, *args, **kwargs)
+ super().__init__(*args, **kwargs)
orate_parser = argparse.ArgumentParser()
orate_parser.add_argument('-s', '--shout', action="store_true", help="N00B EMULATION MODE")
@@ -1395,8 +1378,7 @@ def test_clipboard_failure(capsys):
class CmdResultApp(cmd2.Cmd):
def __init__(self, *args, **kwargs):
- # Need to use this older form of invoking super class constructor to support Python 2.x and Python 3.x
- cmd2.Cmd.__init__(self, *args, **kwargs)
+ super().__init__(*args, **kwargs)
def do_affirmative(self, arg):
self._last_result = cmd2.CmdResult(arg)