How to use _parse_arguments method in autotest

Best Python code snippet using autotest_python

test_cdgprofilergenestoterm.py

Source:test_cdgprofilergenestoterm.py Github

copy

Full Screen

...29 finally:30 shutil.rmtree(temp_dir)31 def test_parse_args(self):32 myargs = ['inputarg']33 res = cdgprofilergenestotermcmd._parse_arguments('desc',34 myargs)35 self.assertEqual('inputarg', res.input)36 self.assertEqual(0.00000001, res.maxpval)37 self.assertEqual(0.05, res.minoverlap)38 self.assertEqual('hsapiens', res.organism)39 self.assertEqual(500, res.maxgenelistsize)40 def test_run_gprofiler_no_file(self):41 temp_dir = tempfile.mkdtemp()42 try:43 tfile = os.path.join(temp_dir, 'foo')44 myargs = [tfile]45 theargs = cdgprofilergenestotermcmd._parse_arguments('desc',46 myargs)47 try:48 cdgprofilergenestotermcmd.run_gprofiler(tfile,49 theargs)50 self.fail('Expected FileNotFoundError')51 except FileNotFoundError:52 pass53 finally:54 shutil.rmtree(temp_dir)55 def test_run_gprofiler_empty_file(self):56 temp_dir = tempfile.mkdtemp()57 try:58 tfile = os.path.join(temp_dir, 'foo')59 open(tfile, 'a').close()60 myargs = [tfile]61 theargs = cdgprofilergenestotermcmd._parse_arguments('desc',62 myargs)63 res = cdgprofilergenestotermcmd.run_gprofiler(tfile,64 theargs)65 self.assertEqual(None, res)66 finally:67 shutil.rmtree(temp_dir)68 def test_run_gprofiler_with_empty_result(self):69 temp_dir = tempfile.mkdtemp()70 try:71 mygprofiler = MagicMock()72 mygprofiler.profile = MagicMock(return_value=pd.DataFrame())73 tfile = os.path.join(temp_dir, 'foo')74 with open(tfile, 'w') as f:75 f.write('a,b,c')76 myargs = [tfile]77 theargs = cdgprofilergenestotermcmd._parse_arguments('desc',78 myargs)79 res = cdgprofilergenestotermcmd.run_gprofiler(tfile,80 theargs,81 gprofwrapper82 =mygprofiler)83 self.assertEqual(None, res)84 mygprofiler.profile.assert_called_once_with(query=['a', 'b', 'c'],85 domain_scope='known',86 organism='hsapiens',87 user_threshold=0.00000001,88 no_evidences=False)89 finally:90 shutil.rmtree(temp_dir)91 def test_run_gprofiler_with_too_many_genes(self):92 temp_dir = tempfile.mkdtemp()93 try:94 tfile = os.path.join(temp_dir, 'foo')95 # write out gene file with 5002 genes which96 # should return None97 with open(tfile, 'w') as f:98 for x in range(0, 5001):99 f.write(str(x) + ',')100 myargs = [tfile]101 theargs = cdgprofilergenestotermcmd._parse_arguments('desc',102 myargs)103 res = cdgprofilergenestotermcmd.run_gprofiler(tfile,104 theargs)105 self.assertEqual(None, res)106 finally:107 shutil.rmtree(temp_dir)108 def test_run_gprofiler_with_empty_result(self):109 temp_dir = tempfile.mkdtemp()110 try:111 mygprofiler = MagicMock()112 df = pd.DataFrame()113 mygprofiler.profile = MagicMock(return_value=df)114 tfile = os.path.join(temp_dir, 'foo')115 with open(tfile, 'w') as f:116 f.write('a,b,c,')117 myargs = [tfile]118 theargs = cdgprofilergenestotermcmd._parse_arguments('desc',119 myargs)120 res = cdgprofilergenestotermcmd.run_gprofiler(tfile,121 theargs,122 gprofwrapper=123 mygprofiler)124 self.assertEqual(None, res)125 mygprofiler.profile.assert_called_once_with(query=['a', 'b', 'c'],126 domain_scope='known',127 organism='hsapiens',128 user_threshold=0.00000001,129 no_evidences=False)130 finally:131 shutil.rmtree(temp_dir)132 def test_run_gprofiler_with_no_result_meeting_minoverlap(self):133 temp_dir = tempfile.mkdtemp()134 try:135 mygprofiler = MagicMock()136 df = pd.DataFrame(columns=['name',137 'source',138 'native',139 'p_value',140 'description',141 'intersections',142 'precision',143 'recall',144 'term_size'],145 data=[['name1',146 'source1',147 'native1',148 0.1,149 'desc1',150 ['hi'],151 0.5,152 0.7, 88],153 ['name2',154 'source2',155 'native2',156 0.5,157 'desc2',158 ['bye'],159 0.6,160 0.8, 99]])161 mygprofiler.profile = MagicMock(return_value=df)162 tfile = os.path.join(temp_dir, 'foo')163 with open(tfile, 'w') as f:164 f.write('a,b,c,')165 myargs = [tfile]166 theargs = cdgprofilergenestotermcmd._parse_arguments('desc',167 myargs)168 theargs.minoverlap=0.6169 res = cdgprofilergenestotermcmd.run_gprofiler(tfile,170 theargs,171 gprofwrapper=172 mygprofiler)173 self.assertEqual(None, res)174 mygprofiler.profile.assert_called_once_with(query=['a', 'b', 'c'],175 domain_scope='known',176 organism='hsapiens',177 user_threshold=0.00000001,178 no_evidences=False)179 finally:180 shutil.rmtree(temp_dir)181 def test_run_gprofiler_with_no_result_cause_sources_in_exclude_list(self):182 temp_dir = tempfile.mkdtemp()183 try:184 mygprofiler = MagicMock()185 df = pd.DataFrame(columns=['name',186 'source',187 'native',188 'p_value',189 'description',190 'intersections',191 'precision',192 'recall',193 'term_size'],194 data=[['name1',195 'TF',196 'native1',197 0.1,198 'desc1',199 ['hi'],200 0.5,201 0.7, 88],202 ['name2',203 'MIRNA',204 'native2',205 0.5,206 'desc2',207 ['bye'],208 0.6,209 0.8, 99],210 ['name2',211 'HP',212 'native2',213 0.5,214 'desc2',215 ['bye'],216 0.6,217 0.8, 99]218 ])219 mygprofiler.profile = MagicMock(return_value=df)220 tfile = os.path.join(temp_dir, 'foo')221 with open(tfile, 'w') as f:222 f.write('a,b,c,')223 myargs = [tfile]224 theargs = cdgprofilergenestotermcmd._parse_arguments('desc',225 myargs)226 res = cdgprofilergenestotermcmd.run_gprofiler(tfile,227 theargs,228 gprofwrapper=229 mygprofiler)230 self.assertEqual(None, res)231 mygprofiler.profile.assert_called_once_with(query=['a', 'b', 'c'],232 domain_scope='known',233 organism='hsapiens',234 user_threshold=0.00000001,235 no_evidences=False)236 finally:237 shutil.rmtree(temp_dir)238 def test_run_gprofiler_with_valid_result(self):239 temp_dir = tempfile.mkdtemp()240 try:241 mygprofiler = MagicMock()242 df = pd.DataFrame(columns=['name',243 'source',244 'native',245 'p_value',246 'description',247 'intersections',248 'precision',249 'recall',250 'term_size'],251 data=[['name1',252 'source1',253 'native1',254 0.1,255 'desc1',256 ['hi'],257 0.5,258 0.7, 88],259 ['name2',260 'source2',261 'native2',262 0.5,263 'desc2',264 ['bye'],265 0.6,266 0.8, 99]])267 mygprofiler.profile = MagicMock(return_value=df)268 tfile = os.path.join(temp_dir, 'foo')269 with open(tfile, 'w') as f:270 f.write('a,b,c,')271 myargs = [tfile]272 theargs = cdgprofilergenestotermcmd._parse_arguments('desc',273 myargs)274 res = cdgprofilergenestotermcmd.run_gprofiler(tfile,275 theargs,276 gprofwrapper=277 mygprofiler)278 self.assertEqual('name2', res['name'])279 self.assertEqual(['bye'], res['intersections'])280 self.assertEqual(99, res['term_size'])281 self.assertEqual(0.5, res['p_value'])282 self.assertEqual('source2', res['source'])283 self.assertEqual('native2', res['sourceTermId'])284 self.assertEqual(0.522, res['jaccard'])285 mygprofiler.profile.assert_called_once_with(query=['a', 'b', 'c'],286 domain_scope='known',287 organism='hsapiens',288 user_threshold=0.00000001,289 no_evidences=False)290 finally:291 shutil.rmtree(temp_dir)292 def test_run_gprofiler_with_valid_no_intersections_in_result(self):293 temp_dir = tempfile.mkdtemp()294 try:295 mygprofiler = MagicMock()296 df = pd.DataFrame(columns=['name',297 'source',298 'native',299 'p_value',300 'description',301 'intersections',302 'precision',303 'recall',304 'term_size'],305 data=[['name1',306 'source1',307 'native1',308 0.1,309 'desc1',310 ['hi'],311 0.5,312 0.7, 88],313 ['name2',314 'source2',315 'native2',316 0.5,317 'desc2',318 ['bye'],319 0.6,320 0.8, 99]])321 mygprofiler.profile = MagicMock(return_value=df)322 tfile = os.path.join(temp_dir, 'foo')323 with open(tfile, 'w') as f:324 f.write('a,b,c,')325 myargs = [tfile]326 theargs = cdgprofilergenestotermcmd._parse_arguments('desc',327 myargs)328 theargs.omit_intersections = True329 res = cdgprofilergenestotermcmd.run_gprofiler(tfile,330 theargs,331 gprofwrapper=332 mygprofiler)333 self.assertEqual('name2', res['name'])334 self.assertEqual([], res['intersections'])335 self.assertEqual(99, res['term_size'])336 self.assertEqual(0.5, res['p_value'])337 self.assertEqual('source2', res['source'])338 self.assertEqual('native2', res['sourceTermId'])339 self.assertEqual(0.522, res['jaccard'])340 mygprofiler.profile.assert_called_once_with(query=['a', 'b', 'c'],...

Full Screen

Full Screen

test_cmd.py

Source:test_cmd.py Github

copy

Full Screen

...126 log.output[1], '^WARNING:quibble.cmd:EXT_DEPENDENCIES'127 )128 @mock.patch('quibble.is_in_docker', return_value=False)129 def test_args_defaults(self, _):130 args = cmd._parse_arguments([])131 self.assertEqual('ref', args.git_cache)132 self.assertEqual(os.getcwd(), args.workspace)133 self.assertEqual('log', args.log_dir)134 @mock.patch('quibble.is_in_docker', return_value=True)135 def test_args_defaults_in_docker(self, _):136 args = cmd._parse_arguments([])137 self.assertEqual('/srv/git', args.git_cache)138 self.assertEqual('/workspace', args.workspace)139 @mock.patch.dict(os.environ, clear=True)140 def test_setup_environment(self):141 q = cmd.QuibbleCmd()142 with mock.patch('quibble.is_in_docker', return_value=True):143 # In Docker we always use self.workspace144 q._setup_environment(145 workspace='/testworkspace',146 mw_install_path='',147 log_dir='',148 tmp_dir='',149 )150 self.assertEqual(os.environ['WORKSPACE'], '/testworkspace')151 with mock.patch.dict(152 os.environ, {'WORKSPACE': '/fromenv'}, clear=True153 ):154 # In Docker, ignore $WORKSPACE155 q._setup_environment(156 workspace='/testworkspace',157 mw_install_path='',158 log_dir='',159 tmp_dir='',160 )161 self.assertEqual(os.environ['WORKSPACE'], '/testworkspace')162 with mock.patch('quibble.is_in_docker', return_value=False):163 q._setup_environment(164 workspace='/testworkspace',165 mw_install_path='',166 log_dir='',167 tmp_dir='',168 )169 self.assertEqual(os.environ['WORKSPACE'], '/testworkspace')170 with mock.patch.dict(171 os.environ, {'WORKSPACE': '/fromenv'}, clear=True172 ):173 # When not in Docker, we honor $WORKSPACE174 q._setup_environment(175 workspace='/testworkspace',176 mw_install_path='',177 log_dir='',178 tmp_dir='',179 )180 self.assertEqual(os.environ['WORKSPACE'], '/fromenv')181 @mock.patch.dict(os.environ, clear=True)182 def test_setup_environment_has_log_directories(self):183 q = cmd.QuibbleCmd()184 q._setup_environment(185 workspace='/workspace',186 mw_install_path='',187 log_dir='/mylog',188 tmp_dir='',189 )190 self.assertIn('LOG_DIR', os.environ)191 self.assertIn('MW_LOG_DIR', os.environ)192 self.assertEqual(os.environ['LOG_DIR'], '/mylog')193 self.assertEqual(os.environ['MW_LOG_DIR'], '/mylog')194 def test_should_run_accepts_all_stages_by_default(self):195 q = cmd.QuibbleCmd()196 args = cmd._parse_arguments(args=[])197 stages = q._stages_to_run(args.run, args.skip, args.commands)198 self.assertEqual(199 default_stages, stages, 'must runs all stages by default'200 )201 def test_should_run_runall_accepts_all_stages(self):202 q = cmd.QuibbleCmd()203 args = cmd._parse_arguments(args=['--run', 'all'])204 stages = q._stages_to_run(args.run, args.skip, args.commands)205 self.assertEqual(default_stages, stages, '--run=all runs all stages')206 def test_should_run_skippall_runs_no_stage(self):207 q = cmd.QuibbleCmd()208 args = cmd._parse_arguments(args=['--skip', 'all'])209 stages = q._stages_to_run(args.run, args.skip, args.commands)210 self.assertEqual([], stages, '--skip=all skips all stages')211 @mock.patch('quibble.cmd.default_stages', ['foo', 'phpunit'])212 def test_should_run_skips_a_stage(self):213 q = cmd.QuibbleCmd()214 args = cmd._parse_arguments(args=['--skip', 'phpunit'])215 stages = q._stages_to_run(args.run, args.skip, args.commands)216 self.assertEqual(['foo'], stages, '--skip skips the stage')217 def test_should_run_runall_and_skip_play_nice(self):218 q = cmd.QuibbleCmd()219 args = cmd._parse_arguments(args=['--run', 'all', '--skip', 'phpunit'])220 stages = q._stages_to_run(args.run, args.skip, args.commands)221 expected_stages = default_stages.copy()222 expected_stages.remove('phpunit')223 self.assertEqual(expected_stages, stages, '--run=all respects --skip')224 def test_should_run_running_a_single_stage(self):225 q = cmd.QuibbleCmd()226 args = cmd._parse_arguments(args=['--run', 'phpunit'])227 stages = q._stages_to_run(args.run, args.skip, args.commands)228 self.assertEqual(229 ['phpunit'], stages, '--run runs exactly the given stage'230 )231 def test_command_skip_all_stages(self):232 q = cmd.QuibbleCmd()233 args = cmd._parse_arguments(args=['-c', '/bin/true'])234 stages = q._stages_to_run(args.run, args.skip, args.commands)235 self.assertEqual([], stages, 'User command must skip all stages')236 def test_run_option_is_comma_separated(self):237 args = cmd._parse_arguments(args=['--run=phpunit,qunit'])238 self.assertEqual(['phpunit', 'qunit'], args.run)239 def test_run_option_does_not_shallow_next_arg(self):240 args = cmd._parse_arguments(args=['--run', 'phpunit', 'repo'])241 self.assertEqual(['phpunit'], args.run)242 self.assertEqual(['repo'], args.projects)243 def test_skip_option_is_comma_separated(self):244 args = cmd._parse_arguments(args=['--skip=phpunit,qunit'])245 self.assertEqual(['phpunit', 'qunit'], args.skip)246 def test_skip_option_does_not_shallow_next_arg(self):247 args = cmd._parse_arguments(args=['--skip', 'phpunit', 'repo'])248 self.assertEqual(['phpunit'], args.skip)249 self.assertEqual(['repo'], args.projects)250 def test_command_does_not_shallow_next_arg(self):251 args = cmd._parse_arguments(args=['--command', '/bin/true', 'repo'])252 self.assertEqual(['/bin/true'], args.commands)253 self.assertEqual(['repo'], args.projects)254 def test_command_used_multiple_times(self):255 args = cmd._parse_arguments(args=['-c', 'true', '-c', 'false'])256 self.assertEqual(['true', 'false'], args.commands)257 def test_project_branch_arg(self):258 args = cmd._parse_arguments(args=[])259 self.assertEqual([], args.project_branch)260 def test_build_execution_plan(self):261 args = cmd._parse_arguments(args=[])262 plan = cmd.QuibbleCmd().build_execution_plan(args)263 self.assertIsInstance(plan[0], quibble.commands.ReportVersions)264 self.assertIsInstance(plan[1], quibble.commands.EnsureDirectory)265 @mock.patch('quibble.commands.execute_command')266 def test_main_execute_build_plan_without_dry_run(self, execute_command):267 with mock.patch('sys.argv', ['quibble']):268 cmd.main()269 self.assertGreater(270 execute_command.call_count,271 2,272 'execute_command must have been called',273 )274 @mock.patch('quibble.commands.execute_command')275 def test_main_execute_build_plan_with_dry_run(self, execute_command):276 with mock.patch('sys.argv', ['quibble', '--dry-run']):277 cmd.main()278 execute_command.assert_not_called()279 @mock.patch('quibble.is_in_docker', return_value=False)280 def test_build_execution_plan_adds_ZUUL_PROJECT(self, _):281 env = {'ZUUL_PROJECT': 'mediawiki/extensions/ZuulProjectEnvVar'}282 with mock.patch.dict('os.environ', env, clear=True):283 q = cmd.QuibbleCmd()284 args = cmd._parse_arguments(args=['--packages-source=composer'])285 with mock.patch('quibble.commands.ZuulClone') as mock_clone:286 q.build_execution_plan(args)287 self.assertEqual(288 [289 'mediawiki/core', # must be first290 'mediawiki/extensions/ZuulProjectEnvVar',291 'mediawiki/skins/Vector',292 ],293 mock_clone.call_args[1]['projects'],294 )295 @mock.patch('quibble.is_in_docker', return_value=False)296 def test_build_execution_plan_does_not_duplicate_hardcoded_repos(self, _):297 hardcoded_repos = [298 'mediawiki/core',299 'mediawiki/skins/Vector',300 ]301 for repo in hardcoded_repos:302 q = cmd.QuibbleCmd()303 args = cmd._parse_arguments(args=['--packages-source=composer'])304 with mock.patch.dict(305 'os.environ', {'ZUUL_PROJECT': repo}, clear=True306 ):307 with mock.patch('quibble.commands.ZuulClone') as mock_clone:308 q.build_execution_plan(args)309 self.assertEqual(310 [311 'mediawiki/core', # must be first312 'mediawiki/skins/Vector',313 ],314 mock_clone.call_args[1]['projects'],315 )316 def test_execute(self):317 q = cmd.QuibbleCmd()...

Full Screen

Full Screen

handlers.py

Source:handlers.py Github

copy

Full Screen

...38class _RunnableHandler(object):39 def __init__(self, library, handler_name, handler_method, doc='', tags=None):40 self.library = library41 self.name = self._get_name(handler_name, handler_method)42 self.arguments = self._parse_arguments(handler_method)43 self._handler_name = handler_name44 self._method = self._get_initial_handler(library, handler_name,45 handler_method)46 doc, tags_from_doc = utils.split_tags_from_doc(doc or '')47 tags_from_attr = self._get_tags_from_attribute(handler_method)48 self._doc = doc49 self.tags = Tags(tuple(tags_from_doc) +50 tuple(tags_from_attr) +51 tuple(tags or ()))52 def _get_name(self, handler_name, handler_method):53 robot_name = getattr(handler_method, 'robot_name', None)54 name = robot_name or utils.printable_name(handler_name, code_style=True)55 if not name:56 raise DataError('Keyword name cannot be empty.')57 return name58 def _parse_arguments(self, handler_method):59 raise NotImplementedError60 def _get_tags_from_attribute(self, handler_method):61 tags = getattr(handler_method, 'robot_tags', ())62 if not utils.is_list_like(tags):63 raise DataError("Expected tags to list like, got %s."64 % utils.type_name(tags))65 return tags66 def _get_initial_handler(self, library, name, method):67 if library.scope.is_global:68 return self._get_global_handler(method, name)69 return None70 def resolve_arguments(self, args, variables=None):71 return self.arguments.resolve(args, variables)72 @property73 def doc(self):74 return self._doc75 @property76 def longname(self):77 return '%s.%s' % (self.library.name, self.name)78 @property79 def shortdoc(self):80 return self.doc.splitlines()[0] if self.doc else ''81 @property82 def libname(self):83 return self.library.name84 def create_runner(self, name):85 return LibraryKeywordRunner(self)86 def current_handler(self):87 if self._method:88 return self._method89 return self._get_handler(self.library.get_instance(), self._handler_name)90 def _get_global_handler(self, method, name):91 return method92 def _get_handler(self, lib_instance, handler_name):93 return getattr(lib_instance, handler_name)94class _PythonHandler(_RunnableHandler):95 def __init__(self, library, handler_name, handler_method):96 _RunnableHandler.__init__(self, library, handler_name, handler_method,97 utils.getdoc(handler_method))98 def _parse_arguments(self, handler_method):99 return PythonArgumentParser().parse(handler_method, self.longname)100class _JavaHandler(_RunnableHandler):101 def __init__(self, library, handler_name, handler_method):102 _RunnableHandler.__init__(self, library, handler_name, handler_method)103 signatures = self._get_signatures(handler_method)104 self._arg_coercer = JavaArgumentCoercer(signatures, self.arguments)105 def _parse_arguments(self, handler_method):106 signatures = self._get_signatures(handler_method)107 return JavaArgumentParser().parse(signatures, self.longname)108 def _get_signatures(self, handler):109 code_object = getattr(handler, 'im_func', handler)110 return code_object.argslist[:code_object.nargs]111 def resolve_arguments(self, args, variables=None):112 positional, named = self.arguments.resolve(args, variables,113 dict_to_kwargs=True)114 arguments = self._arg_coercer.coerce(positional, named,115 dryrun=not variables)116 return arguments, []117class _DynamicHandler(_RunnableHandler):118 def __init__(self, library, handler_name, dynamic_method, doc='',119 argspec=None, tags=None):120 self._argspec = argspec121 _RunnableHandler.__init__(self, library, handler_name,122 dynamic_method.method, doc, tags)123 self._run_keyword_method_name = dynamic_method.name124 self._supports_kwargs = dynamic_method.supports_kwargs125 if argspec and argspec[-1].startswith('**'):126 if not self._supports_kwargs:127 raise DataError("Too few '%s' method parameters for **kwargs "128 "support." % self._run_keyword_method_name)129 def _parse_arguments(self, handler_method):130 return DynamicArgumentParser().parse(self._argspec, self.longname)131 def resolve_arguments(self, arguments, variables=None):132 positional, named = self.arguments.resolve(arguments, variables)133 arguments, kwargs = self.arguments.map(positional, named)134 return arguments, kwargs135 def _get_handler(self, lib_instance, handler_name):136 runner = getattr(lib_instance, self._run_keyword_method_name)137 return self._get_dynamic_handler(runner, handler_name)138 def _get_global_handler(self, method, name):139 return self._get_dynamic_handler(method, name)140 def _get_dynamic_handler(self, runner, name):141 def handler(*positional, **kwargs):142 if self._supports_kwargs:143 return runner(name, positional, kwargs)144 else:145 return runner(name, positional)146 return handler147class _RunKeywordHandler(_PythonHandler):148 def create_runner(self, name):149 default_dry_run_keywords = ('name' in self.arguments.positional and150 self._args_to_process)151 return RunKeywordRunner(self, default_dry_run_keywords)152 @property153 def _args_to_process(self):154 return RUN_KW_REGISTER.get_args_to_process(self.library.orig_name,155 self.name)156 def resolve_arguments(self, args, variables=None):157 args_to_process = self._args_to_process158 return self.arguments.resolve(args, variables, resolve_named=False,159 resolve_variables_until=args_to_process)160class _DynamicRunKeywordHandler(_DynamicHandler, _RunKeywordHandler):161 _parse_arguments = _RunKeywordHandler._parse_arguments162 resolve_arguments = _RunKeywordHandler.resolve_arguments163class _PythonInitHandler(_PythonHandler):164 def __init__(self, library, handler_name, handler_method, docgetter):165 _PythonHandler.__init__(self, library, handler_name, handler_method)166 self._docgetter = docgetter167 @property168 def doc(self):169 if self._docgetter:170 self._doc = self._docgetter() or self._doc171 self._docgetter = None172 return self._doc173 def _parse_arguments(self, handler_method):174 parser = PythonArgumentParser(type='Test Library')175 return parser.parse(handler_method, self.library.name)176class _JavaInitHandler(_JavaHandler):177 def __init__(self, library, handler_name, handler_method, docgetter):178 _JavaHandler.__init__(self, library, handler_name, handler_method)179 self._docgetter = docgetter180 @property181 def doc(self):182 if self._docgetter:183 self._doc = self._docgetter() or self._doc184 self._docgetter = None185 return self._doc186 def _parse_arguments(self, handler_method):187 parser = JavaArgumentParser(type='Test Library')188 signatures = self._get_signatures(handler_method)189 return parser.parse(signatures, self.library.name)190class EmbeddedArgumentsHandler(object):191 def __init__(self, name_regexp, orig_handler):192 self.arguments = ArgumentSpec() # Show empty argument spec for Libdoc193 self._orig_handler = orig_handler194 self.name_regexp = name_regexp195 def __getattr__(self, item):196 return getattr(self._orig_handler, item)197 def matches(self, name):198 return self.name_regexp.match(name) is not None199 def create_runner(self, name):200 return EmbeddedArgumentsRunner(self, name)...

Full Screen

Full Screen

test_extract.py

Source:test_extract.py Github

copy

Full Screen

...6import extract7from tests.conftest import assert_files_changes8def test_parse_input_not_exists(files):9 with pytest.raises(SystemExit):10 extract._parse_arguments("asdf.tar.gz")11def test_parse_empty_args(files):12 with pytest.raises(SystemExit):13 extract._parse_arguments("", "")14def test_parse_output_exists(files):15 with pytest.raises(SystemExit):16 extract._parse_arguments("file1", "file2")17def test_parse_output_not_specified(files):18 compress.run("file1", "new.zip")19 input_file, output_file = extract._parse_arguments("new.zip")20 assert output_file == "new"21 compress.run("file1", "new.tar.gz")22 input_file, output_file = extract._parse_arguments("new.tar.gz")23 assert output_file == "new"24def test_parse_input_cannot_deduct(files):25 with pytest.raises(SystemExit):26 input_file, output_file = extract._parse_arguments("file1")27def test_parse_ok(files):28 input_file, output_file = extract._parse_arguments("file1", "newfile")29 assert input_file == "file1"30 assert output_file == "newfile"31def test_main(files):32 compress.run("file1")33 extract._main("file1.tgz", "file1extracted")34 with open("file1", "r") as f1, open("file1extracted", "r") as f2:35 assert f1.read() == f2.read()36 files["f_root"].append("file1.tgz")37 files["f_root"].append("file1extracted")38 assert_files_changes(files)39def test_main_different_path(files):40 compress.run("file1")41 extract._main("file1.tgz", "dir2/file1")42 files["f_root"].append("file1.tgz")...

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 autotest 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