diff options
| author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2021-01-31 22:29:57 -0500 |
|---|---|---|
| committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2021-01-31 22:29:57 -0500 |
| commit | f456b802754c3d1095b488d670bebba21018d823 (patch) | |
| tree | bf7011f585a8a35ab4cc7ff98aaeebed4de87f84 /plugins | |
| parent | 918200c02d392c17862fff81bbf58820ed15c725 (diff) | |
| download | cmd2-git-f456b802754c3d1095b488d670bebba21018d823.tar.gz | |
Add black for automatic code format
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/ext_test/cmd2_ext_test/__init__.py | 8 | ||||
| -rw-r--r-- | plugins/ext_test/examples/example.py | 1 | ||||
| -rw-r--r-- | plugins/ext_test/setup.py | 20 | ||||
| -rw-r--r-- | plugins/ext_test/tasks.py | 14 | ||||
| -rw-r--r-- | plugins/ext_test/tests/test_ext_test.py | 4 | ||||
| -rw-r--r-- | plugins/tasks.py | 12 | ||||
| -rw-r--r-- | plugins/template/cmd2_myplugin/myplugin.py | 5 | ||||
| -rw-r--r-- | plugins/template/examples/example.py | 1 | ||||
| -rw-r--r-- | plugins/template/setup.py | 16 | ||||
| -rw-r--r-- | plugins/template/tests/test_myplugin.py | 7 |
10 files changed, 30 insertions, 58 deletions
diff --git a/plugins/ext_test/cmd2_ext_test/__init__.py b/plugins/ext_test/cmd2_ext_test/__init__.py index ded8612c..2cc38807 100644 --- a/plugins/ext_test/cmd2_ext_test/__init__.py +++ b/plugins/ext_test/cmd2_ext_test/__init__.py @@ -17,10 +17,6 @@ except importlib_metadata.PackageNotFoundError: # pragma: no cover # package is not installed __version__ = 'unknown' -from .cmd2_ext_test import ( - ExternalTestMixin, -) +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..3bfdf7e7 100644 --- a/plugins/ext_test/examples/example.py +++ b/plugins/ext_test/examples/example.py @@ -8,6 +8,7 @@ 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 c78a8612..7dc55f6a 100644 --- a/plugins/ext_test/setup.py +++ b/plugins/ext_test/setup.py @@ -23,26 +23,19 @@ PACKAGE_DATA = { setuptools.setup( name='cmd2-ext-test', version=scm_version, - 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', - package_data=PACKAGE_DATA, packages=['cmd2_ext_test'], - python_requires='>=3.5', install_requires=['cmd2 >= 0.9.4, <=2'], - setup_requires=[ - 'setuptools >= 42', - 'setuptools_scm >= 3.4'], - + setup_requires=['setuptools >= 42', 'setuptools_scm >= 3.4'], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', @@ -57,17 +50,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 d55911c3..39783158 100644 --- a/plugins/ext_test/tests/test_ext_test.py +++ b/plugins/ext_test/tests/test_ext_test.py @@ -20,6 +20,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) @@ -31,11 +32,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 @@ -62,6 +65,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 f198c34e..7d347454 100644 --- a/plugins/tasks.py +++ b/plugins/tasks.py @@ -10,17 +10,11 @@ Make sure you satisfy the following Python module requirements if you are trying """ import invoke -from plugins.ext_test import ( - tasks as ext_test_tasks, -) -from plugins.template import ( - tasks as template_tasks, -) +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 c0467366..8397e370 100644 --- a/plugins/template/cmd2_myplugin/myplugin.py +++ b/plugins/template/cmd2_myplugin/myplugin.py @@ -63,10 +63,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..49a3df01 100644 --- a/plugins/template/examples/example.py +++ b/plugins/template/examples/example.py @@ -7,6 +7,7 @@ import cmd2_myplugin 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 a61490ca..8d29b3b1 100644 --- a/plugins/template/tests/test_myplugin.py +++ b/plugins/template/tests/test_myplugin.py @@ -2,9 +2,7 @@ # coding=utf-8 import cmd2_myplugin -from cmd2 import ( - cmd2, -) +from cmd2 import cmd2 ###### # @@ -15,6 +13,7 @@ from cmd2 import ( 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) @@ -22,6 +21,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 @@ -45,6 +45,7 @@ def init_app(): # ##### + def test_say(capsys): # call our initialization function instead of using a fixture app = init_app() |
