How to use configure_argument_parser method in Slash

Best Python code snippet using slash

lldb_utilities.py

Source:lldb_utilities.py Github

copy

Full Screen

...68 return cls.argument_parser().format_help()69 @classmethod70 def argument_parser(cls):71 parser = argparse.ArgumentParser(prog=cls.command_name(), description=cls.__doc__)72 cls.configure_argument_parser(parser)73 return parser74 @classmethod75 def configure_argument_parser(cls, parser):76 pass77class DebuggerCommandDumpNsdata(DebuggerCommand):78 """Dumps NSData instances to a file"""79 def run(self):80 if self.args.output:81 self.args.output = os.path.expanduser(self.args.output)82 else:83 self.args.output = self.temporary_file_path(prefix='nsdata-', suffix='.dat')84 cmd = '(BOOL)[({}) writeToFile:@"{}" atomically:YES]'.format(self.expression, self.args.output)85 value = self.value_for_expression(cmd)86 did_write = value.GetValueAsSigned()87 if not did_write:88 self.result.PutCString('Failed to write to {} (permission error?)'.format(self.args.output))89 self.result.SetStatus (lldb.eReturnStatusFailed)90 return91 self.result.PutCString(self.args.output)92 if self.args.reveal:93 cmd = '(void)[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:@[(NSURL *)[NSURL fileURLWithPath:@"{}"]]]'.format(self.args.output)94 self.value_for_expression(cmd)95 if self.args.clipboard:96 self.copy_object_expression_result_to_clipboard('@"{}"'.format(self.args.output))97 98 @classmethod99 def configure_argument_parser(cls, parser):100 parser.add_argument('expression', nargs='+')101 parser.add_argument('-output', help='output path')102 parser.add_argument('-clipboard', action='store_true', help='copy output path to clipboard')103 parser.add_argument('-reveal', action='store_true', help='reveal output file in Finder')104class DebuggerCommandCopyObjectDescriptionToClipboard(DebuggerCommand):105 """Print the description of an Objective-C object and copy it to the clipboard (Like "po")"""106 def run(self):107 value = self.value_for_expression(self.command)108 object_description = value.GetObjectDescription()109 self.result.PutCString(object_description)110 self.copy_object_expression_result_to_clipboard('[({}) description]'.format(self.command))111 @classmethod112 def configure_argument_parser(cls, parser):113 parser.add_argument('expression', nargs='+')114 @classmethod115 def command_name(cls):116 return 'poc'117class DebuggerCommandCopyDescriptionToClipboard(DebuggerCommand):118 """Print the description of an expression and copy it to the clipboard (Like "p")"""119 def run(self):120 value = self.value_for_expression(self.command)121 stream = lldb.SBStream()122 value.GetDescription(stream)123 description = stream.GetData()124 (description,) = re.findall(r'^[^=]+= (.*)', description)125 126 readable_description = re.findall(r'^0x\w+ (.+)', description)127 if readable_description:128 description = readable_description[0]129 self.result.PutCString(description)130 @classmethod131 def configure_argument_parser(cls, parser):132 parser.add_argument('expression', nargs='+')133 @classmethod134 def command_name(cls):135 return 'pp'136class DebuggerCommandTempdir(DebuggerCommand):137 """Print the value of NSTemporaryDirectory() and copy it to the clipboard"""138 def run(self):139 path = self.temporary_directory()140 self.result.PutCString(path)141 self.copy_object_expression_result_to_clipboard('@"{}"'.format(path))142 def needs_expression(self):143 return False144def invocation_proxy(original_function):145 def call_proxy(*args):...

Full Screen

Full Screen

test_script.py

Source:test_script.py Github

copy

Full Screen

...18 assert script.description == ""19 def test_logger(self):20 """The script logger uses the script name."""21 assert SampleScript().logger.name == "sample-script"22 def test_configure_argument_parser(self):23 """configure_argument_parser adds specified arguments."""24 def configure_argument_parser(parser):25 parser.add_argument("test", help="test argument")26 script = SampleScript()27 script.configure_argument_parser = configure_argument_parser28 parser = script.get_parser()29 fh = StringIO()30 parser.print_help(file=fh)31 assert "test argument" in fh.getvalue()32 def test_create_metrics(self):33 """Metrics are created based on the configuration."""34 configs = [35 MetricConfig("m1", "desc1", "counter", {}),36 MetricConfig("m2", "desc2", "histogram", {}),37 ]38 metrics = SampleScript().create_metrics(configs)...

Full Screen

Full Screen

test_configs.py

Source:test_configs.py Github

copy

Full Screen

...28 ('pretty', 'file'),29 'Дополнительные способы вывода данных'30 ),31])32def test_configure_argument_parser(33 action,34 option_string,35 dest,36 choises,37 help_str38):39 got = configs.configure_argument_parser(choises)40 got_actions = [41 g for g in got._actions42 if isinstance(g, action) and g.dest == dest43 ]44 if not len(got_actions):45 assert False, (46 f'Проверьте аргументы парсера. Cli аргумент {dest} не '47 'соответсвует заданию'48 )49 got_action = got_actions[0]50 assert isinstance(got_action, action)51 assert got_action.option_strings == option_string, (52 f'Укажите для аргумента {got_action.help} имя или флаг={option_string}'53 )...

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