diff options
| author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2021-01-31 23:24:47 -0500 |
|---|---|---|
| committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2021-01-31 23:24:47 -0500 |
| commit | 9cb49fb2a3b980f97d5fb27ea37c6dfeee3b9ec4 (patch) | |
| tree | 6d03d9b69ca6472211deb512ab80469f7b7d4802 /tests | |
| parent | 43be550b235f88007c4c1792a7caff38c5ba271f (diff) | |
| download | cmd2-git-9cb49fb2a3b980f97d5fb27ea37c6dfeee3b9ec4.tar.gz | |
Add in isort changes
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/conftest.py | 12 | ||||
| -rw-r--r-- | tests/test_ansi.py | 5 | ||||
| -rw-r--r-- | tests/test_argparse.py | 21 | ||||
| -rw-r--r-- | tests/test_argparse_completer.py | 28 | ||||
| -rw-r--r-- | tests/test_argparse_custom.py | 21 | ||||
| -rwxr-xr-x | tests/test_cmd2.py | 20 | ||||
| -rwxr-xr-x | tests/test_completion.py | 8 | ||||
| -rwxr-xr-x | tests/test_history.py | 62 | ||||
| -rwxr-xr-x | tests/test_parsing.py | 8 | ||||
| -rw-r--r-- | tests/test_plugin.py | 4 | ||||
| -rw-r--r-- | tests/test_run_pyscript.py | 4 | ||||
| -rw-r--r-- | tests/test_table_creator.py | 4 | ||||
| -rw-r--r-- | tests/test_transcript.py | 8 | ||||
| -rw-r--r-- | tests/test_utils.py | 21 |
14 files changed, 171 insertions, 55 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 835739a7..5ed185a3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,12 +12,18 @@ from typing import ( Optional, Union, ) -from unittest import mock +from unittest import ( + mock, +) -from pytest import fixture +from pytest import ( + fixture, +) import cmd2 -from cmd2.utils import StdSim +from cmd2.utils import ( + StdSim, +) # Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) try: diff --git a/tests/test_ansi.py b/tests/test_ansi.py index fd36e9e3..7ebda497 100644 --- a/tests/test_ansi.py +++ b/tests/test_ansi.py @@ -144,7 +144,10 @@ def test_cast_color_as_str(): def test_color_str_building(): - from cmd2.ansi import fg, bg + from cmd2.ansi import ( + bg, + fg, + ) assert fg.blue + "hello" == fg.blue.value + "hello" assert bg.blue + "hello" == bg.blue.value + "hello" diff --git a/tests/test_argparse.py b/tests/test_argparse.py index 72f28abb..131182fd 100644 --- a/tests/test_argparse.py +++ b/tests/test_argparse.py @@ -4,13 +4,17 @@ Cmd2 testing for argument parsing """ import argparse -from typing import Optional +from typing import ( + Optional, +) import pytest import cmd2 -from .conftest import run_cmd +from .conftest import ( + run_cmd, +) # Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) try: @@ -425,8 +429,13 @@ def test_subcmd_decorator(subcommand_app): def test_unittest_mock(): - from unittest import mock - from cmd2 import CommandSetRegistrationError + from unittest import ( + mock, + ) + + from cmd2 import ( + CommandSetRegistrationError, + ) with mock.patch.object(ArgparseApp, 'namespace_provider'): with pytest.raises(CommandSetRegistrationError): @@ -443,7 +452,9 @@ def test_unittest_mock(): def test_pytest_mock_invalid(mocker): - from cmd2 import CommandSetRegistrationError + from cmd2 import ( + CommandSetRegistrationError, + ) mocker.patch.object(ArgparseApp, 'namespace_provider') with pytest.raises(CommandSetRegistrationError): diff --git a/tests/test_argparse_completer.py b/tests/test_argparse_completer.py index 95bb6398..eda27154 100644 --- a/tests/test_argparse_completer.py +++ b/tests/test_argparse_completer.py @@ -5,7 +5,9 @@ Unit/functional testing for argparse completer in cmd2 """ import argparse import numbers -from typing import List +from typing import ( + List, +) import pytest @@ -664,7 +666,9 @@ def test_autocomp_positional_completers(ac_app, pos, text, completions): def test_autocomp_blank_token(ac_app): """Force a blank token to make sure ArgparseCompleter consumes them like argparse does""" - from cmd2.argparse_completer import ArgparseCompleter + from cmd2.argparse_completer import ( + ArgparseCompleter, + ) blank = '' @@ -883,7 +887,9 @@ def test_completion_items_arg_header(ac_app): def test_completion_items_descriptive_header(ac_app): - from cmd2.argparse_completer import DEFAULT_DESCRIPTIVE_HEADER + from cmd2.argparse_completer import ( + DEFAULT_DESCRIPTIVE_HEADER, + ) # This argument provided a descriptive header text = '' @@ -1045,7 +1051,9 @@ def test_complete_mutex_group(ac_app, command_and_args, text, output_contains, f def test_single_prefix_char(): - from cmd2.argparse_completer import _single_prefix_char + from cmd2.argparse_completer import ( + _single_prefix_char, + ) parser = Cmd2ArgumentParser(prefix_chars='-+') @@ -1062,7 +1070,9 @@ def test_single_prefix_char(): def test_looks_like_flag(): - from cmd2.argparse_completer import _looks_like_flag + from cmd2.argparse_completer import ( + _looks_like_flag, + ) parser = Cmd2ArgumentParser() @@ -1080,7 +1090,9 @@ def test_looks_like_flag(): def test_complete_command_no_tokens(ac_app): - from cmd2.argparse_completer import ArgparseCompleter + from cmd2.argparse_completer import ( + ArgparseCompleter, + ) parser = Cmd2ArgumentParser() ac = ArgparseCompleter(parser, ac_app) @@ -1090,7 +1102,9 @@ def test_complete_command_no_tokens(ac_app): def test_complete_command_help_no_tokens(ac_app): - from cmd2.argparse_completer import ArgparseCompleter + from cmd2.argparse_completer import ( + ArgparseCompleter, + ) parser = Cmd2ArgumentParser() ac = ArgparseCompleter(parser, ac_app) diff --git a/tests/test_argparse_custom.py b/tests/test_argparse_custom.py index 86521f61..dd227355 100644 --- a/tests/test_argparse_custom.py +++ b/tests/test_argparse_custom.py @@ -11,9 +11,13 @@ from cmd2 import ( Cmd2ArgumentParser, constants, ) -from cmd2.argparse_custom import generate_range_error +from cmd2.argparse_custom import ( + generate_range_error, +) -from .conftest import run_cmd +from .conftest import ( + run_cmd, +) class ApCustomTestApp(cmd2.Cmd): @@ -264,7 +268,10 @@ def test_apcustom_required_options(): def test_override_parser(): import importlib - from cmd2 import DEFAULT_ARGUMENT_PARSER + + from cmd2 import ( + DEFAULT_ARGUMENT_PARSER, + ) # The standard parser is Cmd2ArgumentParser assert DEFAULT_ARGUMENT_PARSER == Cmd2ArgumentParser @@ -272,10 +279,14 @@ def test_override_parser(): # Set our parser module and force a reload of cmd2 so it loads the module argparse.cmd2_parser_module = 'examples.custom_parser' importlib.reload(cmd2) - from cmd2 import DEFAULT_ARGUMENT_PARSER + from cmd2 import ( + DEFAULT_ARGUMENT_PARSER, + ) # Verify DEFAULT_ARGUMENT_PARSER is now our CustomParser - from examples.custom_parser import CustomParser + from examples.custom_parser import ( + CustomParser, + ) assert DEFAULT_ARGUMENT_PARSER == CustomParser diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index ca88cf99..759ec7d4 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -9,7 +9,9 @@ import io import os import sys import tempfile -from code import InteractiveConsole +from code import ( + InteractiveConsole, +) import pytest @@ -40,7 +42,9 @@ from .conftest import ( try: import mock except ImportError: - from unittest import mock + from unittest import ( + mock, + ) def CreateOutsimApp(): @@ -1018,14 +1022,18 @@ def test_default_to_shell(base_app, monkeypatch): def test_ansi_prompt_not_esacped(base_app): - from cmd2.rl_utils import rl_make_safe_prompt + from cmd2.rl_utils import ( + rl_make_safe_prompt, + ) prompt = '(Cmd) ' assert rl_make_safe_prompt(prompt) == prompt def test_ansi_prompt_escaped(): - from cmd2.rl_utils import rl_make_safe_prompt + from cmd2.rl_utils import ( + rl_make_safe_prompt, + ) app = cmd2.Cmd() color = 'cyan' @@ -2072,7 +2080,9 @@ def test_multiple_macros(base_app): def test_nonexistent_macro(base_app): - from cmd2.parsing import StatementParser + from cmd2.parsing import ( + StatementParser, + ) exception = None diff --git a/tests/test_completion.py b/tests/test_completion.py index ea0ae092..4dcf5575 100755 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -20,8 +20,12 @@ import sys import pytest import cmd2 -from cmd2 import utils -from examples.subcommands import SubcommandsExample +from cmd2 import ( + utils, +) +from examples.subcommands import ( + SubcommandsExample, +) from .conftest import ( complete_tester, diff --git a/tests/test_history.py b/tests/test_history.py index ec05fb19..98ae00b7 100755 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -12,7 +12,9 @@ import cmd2 # Python 3.5 had some regressions in the unitest.mock module, so use # 3rd party mock if available -from cmd2.parsing import StatementParser +from cmd2.parsing import ( + StatementParser, +) from .conftest import ( HELP_HISTORY, @@ -23,14 +25,18 @@ from .conftest import ( try: import mock except ImportError: - from unittest import mock + from unittest import ( + mock, + ) # # readline tests # def test_readline_remove_history_item(base_app): - from cmd2.rl_utils import readline + from cmd2.rl_utils import ( + readline, + ) assert readline.get_current_history_length() == 0 readline.add_history('this is a test') @@ -44,8 +50,13 @@ def test_readline_remove_history_item(base_app): # @pytest.fixture def hist(): - from cmd2.parsing import Statement - from cmd2.cmd2 import History, HistoryItem + from cmd2.cmd2 import ( + History, + HistoryItem, + ) + from cmd2.parsing import ( + Statement, + ) h = History( [ @@ -60,8 +71,13 @@ def hist(): @pytest.fixture def persisted_hist(): - from cmd2.parsing import Statement - from cmd2.cmd2 import History, HistoryItem + from cmd2.cmd2 import ( + History, + HistoryItem, + ) + from cmd2.parsing import ( + Statement, + ) h = History( [ @@ -281,8 +297,12 @@ def test_history_max_length(hist): # @pytest.fixture def histitem(): - from cmd2.parsing import Statement - from cmd2.history import HistoryItem + from cmd2.history import ( + HistoryItem, + ) + from cmd2.parsing import ( + Statement, + ) statement = Statement( 'history', @@ -296,7 +316,9 @@ def histitem(): @pytest.fixture def parser(): - from cmd2.parsing import StatementParser + from cmd2.parsing import ( + StatementParser, + ) parser = StatementParser( terminators=[';', '&'], @@ -314,7 +336,9 @@ def parser(): def test_multiline_histitem(parser): - from cmd2.history import History + from cmd2.history import ( + History, + ) line = 'multiline foo\nbar\n\n' statement = parser.parse(line) @@ -328,7 +352,9 @@ def test_multiline_histitem(parser): def test_multiline_histitem_verbose(parser): - from cmd2.history import History + from cmd2.history import ( + History, + ) line = 'multiline foo\nbar\n\n' statement = parser.parse(line) @@ -343,8 +369,12 @@ def test_multiline_histitem_verbose(parser): def test_history_item_instantiate(): - from cmd2.parsing import Statement - from cmd2.history import HistoryItem + from cmd2.history import ( + HistoryItem, + ) + from cmd2.parsing import ( + Statement, + ) statement = Statement( 'history', @@ -822,7 +852,9 @@ def test_history_populates_readline(hist_file): # readline only adds a single entry for multiple sequential identical commands # so we check to make sure that cmd2 populated the readline history # using the same rules - from cmd2.rl_utils import readline + from cmd2.rl_utils import ( + readline, + ) assert readline.get_current_history_length() == 3 assert readline.get_history_item(1) == 'help' diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 291b0f55..9776dace 100755 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -997,7 +997,9 @@ def test_is_valid_command_valid(parser): def test_macro_normal_arg_pattern(): # This pattern matches digits surrounded by exactly 1 brace on a side and 1 or more braces on the opposite side - from cmd2.parsing import MacroArg + from cmd2.parsing import ( + MacroArg, + ) pattern = MacroArg.macro_normal_arg_pattern @@ -1049,7 +1051,9 @@ def test_macro_normal_arg_pattern(): def test_macro_escaped_arg_pattern(): # This pattern matches digits surrounded by 2 or more braces on both sides - from cmd2.parsing import MacroArg + from cmd2.parsing import ( + MacroArg, + ) pattern = MacroArg.macro_escaped_arg_pattern diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 831b4cef..cd1d9ab9 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -20,7 +20,9 @@ from cmd2 import ( try: import mock except ImportError: - from unittest import mock + from unittest import ( + mock, + ) class Plugin: diff --git a/tests/test_run_pyscript.py b/tests/test_run_pyscript.py index f474684a..2d74a5f0 100644 --- a/tests/test_run_pyscript.py +++ b/tests/test_run_pyscript.py @@ -22,7 +22,9 @@ from .conftest import ( try: import mock except ImportError: - from unittest import mock + from unittest import ( + mock, + ) HOOK_OUTPUT = "TEST_OUTPUT" diff --git a/tests/test_table_creator.py b/tests/test_table_creator.py index f8a63578..64db0dd7 100644 --- a/tests/test_table_creator.py +++ b/tests/test_table_creator.py @@ -5,7 +5,9 @@ Unit testing for cmd2/table_creator.py module """ import pytest -from cmd2 import ansi +from cmd2 import ( + ansi, +) from cmd2.table_creator import ( AlternatingTable, BorderedTable, diff --git a/tests/test_transcript.py b/tests/test_transcript.py index 5f532bd3..48c6a792 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -9,12 +9,16 @@ import random import re import sys import tempfile -from unittest import mock +from unittest import ( + mock, +) import pytest import cmd2 -from cmd2 import transcript +from cmd2 import ( + transcript, +) from cmd2.utils import ( Settable, StdSim, diff --git a/tests/test_utils.py b/tests/test_utils.py index 81d184bf..c14c2f07 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -11,12 +11,16 @@ import time import pytest import cmd2.utils as cu -from cmd2.constants import HORIZONTAL_ELLIPSIS +from cmd2.constants import ( + HORIZONTAL_ELLIPSIS, +) try: import mock except ImportError: - from unittest import mock + from unittest import ( + mock, + ) HELLO_WORLD = 'Hello, world!' @@ -388,7 +392,9 @@ def test_truncate_line_tabs(): def test_truncate_with_style(): - from cmd2 import ansi + from cmd2 import ( + ansi, + ) before_style = ansi.fg.blue + ansi.UNDERLINE_ENABLE after_style = ansi.fg.reset + ansi.UNDERLINE_DISABLE @@ -421,7 +427,9 @@ def test_align_text_fill_char_is_tab(): def test_align_text_with_style(): - from cmd2 import ansi + from cmd2 import ( + ansi, + ) # Single line with only left fill text = ansi.style('line1', fg=ansi.fg.bright_blue) @@ -539,7 +547,10 @@ def test_align_text_has_unprintable(): def test_align_text_term_width(): import shutil - from cmd2 import ansi + + from cmd2 import ( + ansi, + ) text = 'foo' fill_char = ' ' |
