How to use funcSpec method in fMBT

Best Python code snippet using fMBT_python

test_funcspec.py

Source:test_funcspec.py Github

copy

Full Screen

...172 # special check for dependencies list173 extract_deps = lambda s: re.findall(r"\('\w+', '\w+'\)", s)174 assert set(extract_deps(s)) == set(extract_deps(spec[i]))175def test_funcspecs_python(fsargs):176 _compare_with_file(RHSfuncSpec(fsargs)._infostr(verbose=2), "funcspec_python.out")177def test_funcspec_recreate(fsargs):178 del fsargs['codeinsert_start']179 del fsargs['codeinsert_end']180 pyspec = RHSfuncSpec(fsargs)181 cspec_recreated = pyspec.recreate('c')182 fsargs['targetlang'] = 'c'183 cspec = RHSfuncSpec(fsargs)184 assert cspec._infostr(verbose=2) == cspec_recreated._infostr(verbose=2)185def test_funcspecs_c(fsargs):186 fsargs['targetlang'] = 'c'187 fsargs['codeinsert_start'] = "fprintf('code inserted at start\n')"188 fsargs['codeinsert_end'] = "fprintf('code inserted at end\n')"...

Full Screen

Full Screen

funcspec.py

Source:funcspec.py Github

copy

Full Screen

12from tools.utils.ictypes import canonical_ictype, native_ictype, unstringed_ictype, VALID_ICTYPES3from tools.utils.platform import ICTYPE_2_MGDTYPE456#==========================================================================78class _FuncSpec(tuple):9 10 @property11 def ret(self):12 return self[0]13 14 @property15 def args(self):16 return self[1:]1718 @property19 def argspec(self):20 return ''.join(self.args) or 'void'21 22 @property23 def mgd_ret(self):24 return ICTYPE_2_MGDTYPE[self.ret]2526 @property27 def mgd_arglist(self):28 return ', '.join(29 '%s arg%d' % (ICTYPE_2_MGDTYPE[arg], i)30 for (i, arg) in enumerate(self.args))3132 @property33 def canonical(self):34 return _FuncSpec(map(canonical_ictype, self))3536 @property37 def native(self):38 return _FuncSpec(map(native_ictype, self))3940 @property41 def unstringed(self):42 return _FuncSpec(map(unstringed_ictype, self))4344 def withargs(self, newargs):45 return _FuncSpec(self[:1] + tuple(newargs))4647 def __str__(self):48 return '_'.join((self.ret, self.argspec))4950 def __repr__(self):51 return 'FuncSpec("%s")' % self525354#==========================================================================5556def _complain(s):57 raise Exception('could not get ictype from "%s"' % s)5859def _slurp_argspec(argspec):60 while len(argspec):61 for key in VALID_ICTYPES:62 if argspec.startswith(key):63 argspec = argspec[len(key):]64 yield key65 break66 else:67 _complain(argspec)6869def _unpack_argspec(argspec):70 if argspec == 'void':71 return ()72 return tuple(_slurp_argspec(argspec))7374def _unpack_retargs(ret, args):75 return (ret,) + tuple(args)7677def _unpack_funcspec(funcspec):78 ret, argspec = funcspec.split('_')79 if ret not in VALID_ICTYPES:80 _complain(ret)81 args = _unpack_argspec(argspec)82 return _unpack_retargs(ret, args)8384_unpack_nothing = lambda x: x8586_UNPACKERS = {87 (str,): _unpack_funcspec,88 (str, list): _unpack_retargs,89 (str, tuple): _unpack_retargs,90}9192def _get_funcspec_data(input):93 types = tuple(map(type, input))94 unpack = _UNPACKERS.get(types, _unpack_nothing)95 return unpack(*input)969798#==========================================================================99100def FuncSpec(*args):101 return _FuncSpec(_get_funcspec_data(args)).canonical102 103 ...

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