diff options
Diffstat (limited to 'plugins/ext_test')
-rw-r--r-- | plugins/ext_test/cmd2_ext_test/__init__.py | 4 | ||||
-rw-r--r-- | plugins/ext_test/examples/example.py | 4 | ||||
-rw-r--r-- | plugins/ext_test/setup.py | 16 | ||||
-rw-r--r-- | plugins/ext_test/tasks.py | 14 | ||||
-rw-r--r-- | plugins/ext_test/tests/test_ext_test.py | 6 |
5 files changed, 20 insertions, 24 deletions
diff --git a/plugins/ext_test/cmd2_ext_test/__init__.py b/plugins/ext_test/cmd2_ext_test/__init__.py index 21fd000b..2cc38807 100644 --- a/plugins/ext_test/cmd2_ext_test/__init__.py +++ b/plugins/ext_test/cmd2_ext_test/__init__.py @@ -19,6 +19,4 @@ except importlib_metadata.PackageNotFoundError: # pragma: no cover from .cmd2_ext_test import ExternalTestMixin -__all__ = [ - 'ExternalTestMixin' -] +__all__ = ['ExternalTestMixin'] diff --git a/plugins/ext_test/examples/example.py b/plugins/ext_test/examples/example.py index d7f0c762..7dbb6677 100644 --- a/plugins/ext_test/examples/example.py +++ b/plugins/ext_test/examples/example.py @@ -1,13 +1,15 @@ # # coding=utf-8 # import cmd2 +import cmd2_ext_test + import cmd2 import cmd2.py_bridge -import cmd2_ext_test class Example(cmd2.Cmd): """An class to show how to use a plugin""" + def __init__(self, *args, **kwargs): # gotta have this or neither the plugin or cmd2 will initialize super().__init__(*args, **kwargs) diff --git a/plugins/ext_test/setup.py b/plugins/ext_test/setup.py index 3384527c..4bfe1b79 100644 --- a/plugins/ext_test/setup.py +++ b/plugins/ext_test/setup.py @@ -20,23 +20,18 @@ setuptools.setup( # 'relative_to': __file__, # 'git_describe_command': 'git describe --dirty --tags --long --match plugin-ext-test*' # }, - description='External test plugin for cmd2. Allows for external invocation of commands as if from a cmd2 pyscript', long_description=long_description, long_description_content_type='text/markdown', keywords='cmd2 test plugin', - author='Eric Lin', author_email='anselor@gmail.com', url='https://github.com/python-cmd2/cmd2/tree/master/plugins/ext_test', license='MIT', - packages=['cmd2_ext_test'], - python_requires='>=3.5', install_requires=['cmd2 >= 0.9.4, <=2'], setup_requires=['setuptools_scm >= 3.0'], - classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', @@ -51,17 +46,10 @@ setuptools.setup( 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', ], - # dependencies for development and testing # $ pip install -e .[dev] extras_require={ - 'test': [ - 'codecov', - 'coverage', - 'pytest', - 'pytest-cov', - ], - 'dev': ['setuptools_scm', 'pytest', 'codecov', 'pytest-cov', - 'pylint', 'invoke', 'wheel', 'twine'] + 'test': ['codecov', 'coverage', 'pytest', 'pytest-cov',], + 'dev': ['setuptools_scm', 'pytest', 'codecov', 'pytest-cov', 'pylint', 'invoke', 'wheel', 'twine'], }, ) diff --git a/plugins/ext_test/tasks.py b/plugins/ext_test/tasks.py index f23faa69..757dfe79 100644 --- a/plugins/ext_test/tasks.py +++ b/plugins/ext_test/tasks.py @@ -57,7 +57,7 @@ def pytest(context, junit=False, pty=True, append_cov=False): command_str += ' --cov-append' if junit: command_str += ' --junitxml=junit/test-results.xml' - command_str += ' ' + str((TASK_ROOT/'tests').relative_to(ROOT_PATH)) + command_str += ' ' + str((TASK_ROOT / 'tests').relative_to(ROOT_PATH)) context.run(command_str, pty=pty) @@ -71,8 +71,8 @@ def pytest_clean(context): with context.cd(TASK_ROOT_STR): dirs = ['.pytest_cache', '.cache', 'htmlcov', '.coverage'] rmrf(dirs) - - + + namespace_clean.add_task(pytest_clean, 'pytest') @@ -140,6 +140,8 @@ namespace_clean.add_task(dist_clean, 'dist') # # make a dummy clean task which runs all the tasks in the clean namespace clean_tasks = list(namespace_clean.tasks.values()) + + @invoke.task(pre=list(namespace_clean.tasks.values()), default=True) def clean_all(context): """Run all clean tasks""" @@ -195,8 +197,10 @@ namespace.add_task(pypi_test) def flake8(context): """Run flake8 linter and tool for style guide enforcement""" with context.cd(TASK_ROOT_STR): - context.run("flake8 --ignore=E252,W503 --max-complexity=26 --max-line-length=127 --show-source --statistics " - "--exclude=.git,__pycache__,.tox,.nox,.eggs,*.egg,.venv,.idea,.pytest_cache,.vscode,build,dist,htmlcov") + context.run( + "flake8 --ignore=E252,W503 --max-complexity=26 --max-line-length=127 --show-source --statistics " + "--exclude=.git,__pycache__,.tox,.nox,.eggs,*.egg,.venv,.idea,.pytest_cache,.vscode,build,dist,htmlcov" + ) namespace.add_task(flake8) diff --git a/plugins/ext_test/tests/test_ext_test.py b/plugins/ext_test/tests/test_ext_test.py index b1ba1b7d..52441340 100644 --- a/plugins/ext_test/tests/test_ext_test.py +++ b/plugins/ext_test/tests/test_ext_test.py @@ -1,9 +1,9 @@ # # coding=utf-8 +import cmd2_ext_test import pytest -import cmd2_ext_test from cmd2 import CommandResult, cmd2 ###### @@ -17,6 +17,7 @@ OUT_MSG = 'this is the something command' class ExampleApp(cmd2.Cmd): """An class to show how to use a plugin""" + def __init__(self, *args, **kwargs): # gotta have this or neither the plugin or cmd2 will initialize super().__init__(*args, **kwargs) @@ -28,11 +29,13 @@ class ExampleApp(cmd2.Cmd): # Define a tester class that brings in the external test mixin + class ExampleTester(cmd2_ext_test.ExternalTestMixin, ExampleApp): def __init__(self, *args, **kwargs): # gotta have this or neither the plugin or cmd2 will initialize super().__init__(*args, **kwargs) + # # You can't use a fixture to instantiate your app if you want to use # to use the capsys fixture to capture the output. cmd2.Cmd sets @@ -59,6 +62,7 @@ def example_app(): # ##### + def test_something(example_app): # load our fixture # execute a command |