summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ext_test/cmd2_ext_test/__init__.py4
-rw-r--r--plugins/ext_test/examples/example.py4
-rw-r--r--plugins/ext_test/setup.py16
-rw-r--r--plugins/ext_test/tasks.py14
-rw-r--r--plugins/ext_test/tests/test_ext_test.py6
-rw-r--r--plugins/tasks.py4
-rw-r--r--plugins/template/cmd2_myplugin/myplugin.py5
-rw-r--r--plugins/template/examples/example.py4
-rw-r--r--plugins/template/setup.py16
-rw-r--r--plugins/template/tests/test_myplugin.py4
10 files changed, 31 insertions, 46 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
diff --git a/plugins/tasks.py b/plugins/tasks.py
index 1a70e4f2..7d347454 100644
--- a/plugins/tasks.py
+++ b/plugins/tasks.py
@@ -14,9 +14,7 @@ from plugins.ext_test import tasks as ext_test_tasks
from plugins.template import tasks as template_tasks
# create namespaces
-namespace = invoke.Collection(ext_test=ext_test_tasks,
- template=template_tasks,
- )
+namespace = invoke.Collection(ext_test=ext_test_tasks, template=template_tasks,)
namespace_clean = invoke.Collection('clean')
namespace.add_collection(namespace_clean, 'clean')
diff --git a/plugins/template/cmd2_myplugin/myplugin.py b/plugins/template/cmd2_myplugin/myplugin.py
index 816198b0..b89bcd72 100644
--- a/plugins/template/cmd2_myplugin/myplugin.py
+++ b/plugins/template/cmd2_myplugin/myplugin.py
@@ -60,10 +60,7 @@ class MyPluginMixin(_Base):
"""Method to be called after the command loop finishes"""
self.poutput("postloop hook")
- def cmd2_myplugin_postparsing_hook(
- self,
- data: cmd2.plugin.PostparsingData
- ) -> cmd2.plugin.PostparsingData:
+ def cmd2_myplugin_postparsing_hook(self, data: cmd2.plugin.PostparsingData) -> cmd2.plugin.PostparsingData:
"""Method to be called after parsing user input, but before running the command"""
self.poutput('in postparsing hook')
return data
diff --git a/plugins/template/examples/example.py b/plugins/template/examples/example.py
index 2c9b8e5c..b071b5f8 100644
--- a/plugins/template/examples/example.py
+++ b/plugins/template/examples/example.py
@@ -1,12 +1,14 @@
#
# coding=utf-8
-import cmd2
import cmd2_myplugin
+import cmd2
+
class Example(cmd2_myplugin.MyPlugin, 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/template/setup.py b/plugins/template/setup.py
index cb1dfd8e..e0f458e4 100644
--- a/plugins/template/setup.py
+++ b/plugins/template/setup.py
@@ -15,23 +15,18 @@ setuptools.setup(
name='cmd2-myplugin',
# use_scm_version=True, # use_scm_version doesn't work if setup.py isn't in the repository root
version='1.0.1',
-
description='A template used to build plugins for cmd2',
long_description=long_description,
long_description_content_type='text/markdown',
keywords='cmd2 plugin',
-
author='Kotfu',
author_email='kotfu@kotfu.net',
url='https://github.com/python-cmd2/cmd2-plugin-template',
license='MIT',
-
packages=['cmd2_myplugin'],
-
python_requires='>=3.4',
install_requires=['cmd2 >= 0.9.4, <=2'],
setup_requires=['setuptools_scm'],
-
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
@@ -44,17 +39,10 @@ setuptools.setup(
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
-
# 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/template/tests/test_myplugin.py b/plugins/template/tests/test_myplugin.py
index d61181a6..dc3677da 100644
--- a/plugins/template/tests/test_myplugin.py
+++ b/plugins/template/tests/test_myplugin.py
@@ -2,6 +2,7 @@
# coding=utf-8
import cmd2_myplugin
+
from cmd2 import cmd2
######
@@ -13,6 +14,7 @@ from cmd2 import cmd2
class MyApp(cmd2_myplugin.MyPluginMixin, cmd2.Cmd):
"""Simple subclass of cmd2.Cmd with our SayMixin plugin included."""
+
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -20,6 +22,7 @@ class MyApp(cmd2_myplugin.MyPluginMixin, cmd2.Cmd):
def do_empty(self, args):
self.poutput("running the empty command")
+
#
# 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
@@ -43,6 +46,7 @@ def init_app():
#
#####
+
def test_say(capsys):
# call our initialization function instead of using a fixture
app = init_app()