How to use slash_list_plugins method in Slash

Best Python code snippet using slash

main.py

Source:main.py Github

copy

Full Screen

1#!/usr/bin/env python2from __future__ import print_function3import argparse4import contextlib5import colorama6import logbook # pylint: disable=F04017import sys8import os9from ..__version__ import __version__10_COMMANDS = {11 "run": "slash.frontend.slash_run:slash_run",12 "resume": "slash.frontend.slash_run:slash_resume",13 "rerun": "slash.frontend.slash_run:slash_rerun",14 "version": "slash.frontend.main:slash_version",15 "list": "slash.frontend.slash_list:slash_list",16 "list-config": "slash.frontend.list_config:list_config",17 "list-plugins": "slash.frontend.slash_list_plugins:slash_list_plugins",18}19def _get_parser():20 parser = argparse.ArgumentParser(21 formatter_class=argparse.RawDescriptionHelpFormatter,22 epilog="Available commands:\n\t{}".format("\n\t".join(sorted(_COMMANDS))),23 usage="%(prog)s command...",24 )25 parser.add_argument("-v", action="append_const", const=1, dest="verbosity", default=[],26 help="Be more verbose. Can be specified multiple times to increase verbosity further")27 parser.add_argument("cmd")28 parser.add_argument("argv", nargs=argparse.REMAINDER)29 return parser30def main():31 parser = _get_parser()32 args = parser.parse_args()33 with _setup_logging_context(args):34 module_name = _COMMANDS.get(args.cmd)35 if not module_name:36 parser.error("No such command: {}".format(args.cmd))37 module_name, func_name = module_name.split(":")38 module = __import__(module_name, fromlist=[""])39 func = getattr(module, func_name)40 returned = func(args)41 if not isinstance(returned, int):42 returned = returned.exit_code43 return returned44def slash_version(_):45 print('Slash v{}'.format(__version__))46 return 047################################## Boilerplate ################################48_DEFAULT_LOG_LEVEL = logbook.WARNING49@contextlib.contextmanager50def _setup_logging_context(args):51 log_level = max(logbook.DEBUG, _DEFAULT_LOG_LEVEL - len(args.verbosity))52 with logbook.NullHandler().applicationbound():53 with logbook.StderrHandler(level=log_level, bubble=False).applicationbound():54 yield55#### For use with entry_points/console_scripts56def main_entry_point():57 is_windows = os.name == 'nt'58 if is_windows:59 colorama.init()60 try:61 sys.exit(main())62 finally:63 if is_windows:64 colorama.deinit()65if __name__ == "__main__":...

Full Screen

Full Screen

slash_list_plugins.py

Source:slash_list_plugins.py Github

copy

Full Screen

...12 parser = argparse.ArgumentParser('slash list-plugins [options]')13 parser.add_argument('--force-color', dest='force_color', action='store_true', default=False)14 parser.add_argument('--no-color', dest='enable_color', action='store_false', default=True)15 return parser16def slash_list_plugins(args, report_stream=sys.stdout):17 parser = _get_parser()18 parsed_args = parser.parse_args(args.argv)19 _print = Printer(report_stream, force_color=parsed_args.force_color, enable_color=parsed_args.enable_color)20 site.load()21 active = manager.get_future_active_plugins()22 for plugin in sorted(manager.get_installed_plugins(include_internals=False).values(), key=lambda p: p.get_name()):23 name = plugin.get_name()24 normalized_name = manager.normalize_command_line_name(name)25 _print(_title_style(name), end=' ')26 if name in active:27 _print(_enabled_style('active (use --without-{} to deactivate'.format(normalized_name)))28 else:29 _print(_disabled_style('inactive (use --with-{} to activate)'.format(normalized_name)))30 if plugin.__doc__:...

Full Screen

Full Screen

test_list_plugins.py

Source:test_list_plugins.py Github

copy

Full Screen

...3import pytest4from io import StringIO5from slash.frontend.slash_list_plugins import slash_list_plugins6from slash.plugins import manager, PluginInterface7def test_slash_list_plugins(report_stream):8 slash_list_plugins(munch.Munch(argv=[]), report_stream=report_stream)9 output = report_stream.getvalue()10 assert output11 installed = manager.get_installed_plugins()12 for plugin_name in installed:13 assert plugin_name in output14 activate_flag = "--with-{}".format(plugin_name.replace(' ', '-'))15 assert activate_flag in output16def test_slash_list_plugins_for_internal_plugins(report_stream):17 internal_plugin = InternalPlugin()18 manager.install(internal_plugin, is_internal=True)19 slash_list_plugins(munch.Munch(argv=[]), report_stream=report_stream)20 output = report_stream.getvalue()21 assert output22 assert internal_plugin.get_name() in manager.get_installed_plugins()23 assert internal_plugin.get_name() not in output24 assert '--internal-plugin-option' not in output25@pytest.fixture26def report_stream():27 return StringIO()28class InternalPlugin(PluginInterface):29 def get_name(self):30 return "internal plugin"31 def configure_argument_parser(self, parser):32 parser.add_argument("--internal-plugin-option")33 def configure_from_parsed_args(self, args):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful