diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-04-24 21:15:34 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-04-24 21:21:35 -0400 |
commit | 9b78cf4913202995dcf065ecf5077bf16fa01f95 (patch) | |
tree | a04ca95d6f67bae491f290cc71036d2a4f6b168c /tests | |
parent | 9c7bbfa5bdbf8c8d81c0cd3c3cd5179d700de0b2 (diff) | |
download | cmd2-git-9b78cf4913202995dcf065ecf5077bf16fa01f95.tar.gz |
Added info on semantic versioning and branching strategy to CONTRIBUTING.md
Also:
- Added isort to Pipenv dev
- Added setup.cfg to make it easy to run flake8, doc8, and isort directly from the command line without using invoke
- Ran isort to sort includes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conftest.py | 3 | ||||
-rw-r--r-- | tests/pyscript/environment.py | 1 | ||||
-rw-r--r-- | tests/test_argparse.py | 1 | ||||
-rw-r--r-- | tests/test_argparse_completer.py | 5 | ||||
-rw-r--r-- | tests/test_argparse_custom.py | 1 | ||||
-rwxr-xr-x | tests/test_cmd2.py | 19 | ||||
-rwxr-xr-x | tests/test_completion.py | 1 | ||||
-rwxr-xr-x | tests/test_history.py | 7 | ||||
-rwxr-xr-x | tests/test_parsing.py | 1 | ||||
-rw-r--r-- | tests/test_plugin.py | 5 | ||||
-rw-r--r-- | tests/test_run_pyscript.py | 3 | ||||
-rw-r--r-- | tests/test_table_creator.py | 11 | ||||
-rw-r--r-- | tests/test_transcript.py | 11 |
13 files changed, 48 insertions, 21 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 9ee8da19..60074f5c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,7 +3,7 @@ Cmd2 unit/functional testing """ import sys -from contextlib import redirect_stdout, redirect_stderr +from contextlib import redirect_stderr, redirect_stdout from typing import List, Optional, Union from unittest import mock @@ -12,7 +12,6 @@ from pytest import fixture import cmd2 from cmd2.utils import StdSim - # Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) try: import gnureadline as readline diff --git a/tests/pyscript/environment.py b/tests/pyscript/environment.py index 5e4d93d6..f1182c82 100644 --- a/tests/pyscript/environment.py +++ b/tests/pyscript/environment.py @@ -2,6 +2,7 @@ # Tests that cmd2 populates __name__, __file__, and sets sys.path[0] to our directory import os import sys + app.cmd_echo = True if __name__ != '__main__': diff --git a/tests/test_argparse.py b/tests/test_argparse.py index db6dea21..daf43497 100644 --- a/tests/test_argparse.py +++ b/tests/test_argparse.py @@ -9,6 +9,7 @@ from typing import Optional import pytest import cmd2 + from .conftest import run_cmd # Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) diff --git a/tests/test_argparse_completer.py b/tests/test_argparse_completer.py index 9e635a42..4313647b 100644 --- a/tests/test_argparse_completer.py +++ b/tests/test_argparse_completer.py @@ -9,9 +9,10 @@ from typing import List import pytest import cmd2 -from cmd2 import with_argparser, Cmd2ArgumentParser, CompletionItem +from cmd2 import Cmd2ArgumentParser, CompletionItem, with_argparser from cmd2.utils import CompletionError, StdSim, basic_complete -from .conftest import run_cmd, complete_tester + +from .conftest import complete_tester, run_cmd # Lists used in our tests (there is a mix of sorted and unsorted on purpose) static_int_choices_list = [-1, 1, -2, 2, 0, -12] diff --git a/tests/test_argparse_custom.py b/tests/test_argparse_custom.py index 92b2ecb4..f4db12b6 100644 --- a/tests/test_argparse_custom.py +++ b/tests/test_argparse_custom.py @@ -9,6 +9,7 @@ import pytest import cmd2 from cmd2 import Cmd2ArgumentParser, constants from cmd2.argparse_custom import generate_range_error + from .conftest import run_cmd diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index fdeea9aa..33f75c9e 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -13,16 +13,27 @@ from code import InteractiveConsole import pytest +import cmd2 +from cmd2 import COMMAND_NAME, ansi, clipboard, constants, exceptions, plugin, utils + +from .conftest import ( + HELP_HISTORY, + SHORTCUTS_TXT, + SHOW_LONG, + SHOW_TXT, + complete_tester, + normalize, + odd_file_names, + run_cmd, + verify_help_text, +) + # Python 3.5 had some regressions in the unitest.mock module, so use 3rd party mock if available try: import mock except ImportError: from unittest import mock -import cmd2 -from cmd2 import ansi, clipboard, constants, exceptions, plugin, utils, COMMAND_NAME -from .conftest import (run_cmd, normalize, verify_help_text, HELP_HISTORY, SHORTCUTS_TXT, SHOW_TXT, - SHOW_LONG, complete_tester, odd_file_names) def CreateOutsimApp(): c = cmd2.Cmd() diff --git a/tests/test_completion.py b/tests/test_completion.py index e13d87de..a380d43a 100755 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -22,6 +22,7 @@ import pytest import cmd2 from cmd2 import utils from examples.subcommands import SubcommandsExample + from .conftest import complete_tester, normalize, run_cmd # List of strings used with completion functions diff --git a/tests/test_history.py b/tests/test_history.py index 11f189f6..6fa16ad8 100755 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -3,22 +3,23 @@ """ Test history functions of cmd2 """ -import tempfile import os +import tempfile import pytest +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 .conftest import HELP_HISTORY, normalize, run_cmd + try: import mock except ImportError: from unittest import mock -import cmd2 -from .conftest import run_cmd, normalize, HELP_HISTORY # diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 5f363320..c2c242fe 100755 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -10,6 +10,7 @@ import cmd2 from cmd2 import constants, exceptions, utils from cmd2.parsing import StatementParser, shlex_split + @pytest.fixture def parser(): parser = StatementParser( diff --git a/tests/test_plugin.py b/tests/test_plugin.py index bb7753f0..132361a6 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -8,14 +8,15 @@ import sys import pytest +import cmd2 +from cmd2 import Cmd2ArgumentParser, exceptions, plugin, with_argparser + # Python 3.5 had some regressions in the unitest.mock module, so use 3rd party mock if available try: import mock except ImportError: from unittest import mock -import cmd2 -from cmd2 import exceptions, plugin, Cmd2ArgumentParser, with_argparser class Plugin: diff --git a/tests/test_run_pyscript.py b/tests/test_run_pyscript.py index 6110e3ac..8cfd8578 100644 --- a/tests/test_run_pyscript.py +++ b/tests/test_run_pyscript.py @@ -9,7 +9,8 @@ import os import pytest from cmd2 import plugin, utils -from .conftest import run_cmd, odd_file_names + +from .conftest import odd_file_names, run_cmd # Python 3.5 had some regressions in the unitest.mock module, so use 3rd party mock if available try: diff --git a/tests/test_table_creator.py b/tests/test_table_creator.py index 917ba5cc..ed53efa6 100644 --- a/tests/test_table_creator.py +++ b/tests/test_table_creator.py @@ -6,8 +6,15 @@ Unit testing for cmd2/table_creator.py module import pytest from cmd2 import ansi -from cmd2.table_creator import (AlternatingTable, BorderedTable, Column, HorizontalAlignment, - SimpleTable, TableCreator, VerticalAlignment) +from cmd2.table_creator import ( + AlternatingTable, + BorderedTable, + Column, + HorizontalAlignment, + SimpleTable, + TableCreator, + VerticalAlignment, +) def test_column_creation(): diff --git a/tests/test_transcript.py b/tests/test_transcript.py index aa6f8c4e..69389b7f 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -5,18 +5,19 @@ Cmd2 functional testing based on transcript """ import argparse import os -import sys -import re import random +import re +import sys import tempfile - from unittest import mock + import pytest import cmd2 -from .conftest import run_cmd, verify_help_text from cmd2 import transcript -from cmd2.utils import StdSim, Settable +from cmd2.utils import Settable, StdSim + +from .conftest import run_cmd, verify_help_text class CmdLineApp(cmd2.Cmd): |