Best Python code snippet using avocado_python
nrunner.py
Source:nrunner.py
...651 if prog is None:652 prog = self.PROG_NAME653 if description is None:654 description = self.PROG_DESCRIPTION655 self._class_commands_method = self._get_commands_method()656 self._setup_parser(prog, description)657 def _setup_parser(self, prog, description):658 self.parser = argparse.ArgumentParser(prog=prog,659 description=description)660 subcommands = self.parser.add_subparsers(dest='subcommand')661 subcommands.required = True662 for command, method in self._class_commands_method.items():663 command_args = "CMD_%s_ARGS" % command.upper().replace('-', '_')664 command_parser = subcommands.add_parser(665 command,666 help=self._get_command_method_help_message(method))667 if hasattr(self, command_args):668 for arg in getattr(self, command_args):669 command_parser.add_argument(*arg[0], **arg[1])670 def _get_commands_method(self):671 prefix = 'command_'672 return {c[0][len(prefix):].replace('_', '-'): getattr(self, c[0])673 for c in inspect.getmembers(self, inspect.ismethod)674 if c[0].startswith(prefix)}675 def _get_command_method_help_message(self, command_method):676 help_message = ''677 docstring = command_method.__doc__678 if docstring:679 docstring_lines = docstring.strip().splitlines()680 if docstring_lines:681 help_message = docstring_lines[0]682 return help_message683 def run(self):684 """...
app.py
Source:app.py
...116 if prog is None:117 prog = self.PROG_NAME118 if description is None:119 description = self.PROG_DESCRIPTION120 self._class_commands_method = self._get_commands_method()121 self._setup_parser(prog, description)122 def _setup_parser(self, prog, description):123 self.parser = argparse.ArgumentParser(prog=prog, description=description)124 subcommands = self.parser.add_subparsers(dest="subcommand")125 subcommands.required = True126 for command, method in self._class_commands_method.items():127 command_args = f"CMD_{command.upper().replace('-', '_')}_ARGS"128 command_parser = subcommands.add_parser(129 command, help=self._get_command_method_help_message(method)130 )131 if hasattr(self, command_args):132 for arg in getattr(self, command_args):133 command_parser.add_argument(*arg[0], **arg[1])134 def _get_commands_method(self):135 prefix = "command_"136 return {137 c[0][len(prefix) :].replace("_", "-"): getattr(self, c[0])138 for c in inspect.getmembers(self, inspect.ismethod)139 if c[0].startswith(prefix)140 }141 @staticmethod142 def _get_command_method_help_message(command_method):143 help_message = ""144 docstring = command_method.__doc__145 if docstring:146 docstring_lines = docstring.strip().splitlines()147 if docstring_lines:148 help_message = docstring_lines[0]...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!