def _makeOptions(self, **kwargs): o = Opt() o.app = kwargs.get('app', None) o.verbose = kwargs.get('verbose', False) o.compile = kwargs.get('compile', []) o.debug = kwargs.get('debug', False) o.dryrun = kwargs.get('dryrun', False) o.nohandle = kwargs.get('nohandle', False) o.nopdb = kwargs.get('nopdb', True) o.cli = kwargs.get('cli', False) o.fwconfig = kwargs.get('fwconfig', []) o.tests = kwargs.get('tests', []) o.usercode = kwargs.get('usercode', None) o.exclude = kwargs.get('exclude', None) o.intf = kwargs.get('intf', None) o.topology = kwargs.get('topology', None) o.codearg = _parse_codeargs(kwargs.get('codearg', '')) o.logfile = _parse_codeargs(kwargs.get('logfile', None)) return o
def _makeOptions(self, **kwargs): o = Opt() o.app = kwargs.get('app', None) o.verbose = kwargs.get('verbose', False) o.compile = kwargs.get('compile', []) o.debug = kwargs.get('debug', False) o.dryrun = kwargs.get('dryrun', False) o.nohandle = kwargs.get('nohandle', False) o.nopdb = kwargs.get('nopdb', True) o.cli = kwargs.get('cli', False) o.fwconfig = kwargs.get('fwconfig', []) o.tests = kwargs.get('tests', []) o.usercode = kwargs.get('usercode', None) o.exclude = kwargs.get('exclude', None) o.intf = kwargs.get('intf', None) o.topology = kwargs.get('topology', None) o.codearg = _parse_codeargs(kwargs.get('codearg', '')) o.logfile = _parse_codeargs(kwargs.get('logfile', None)) o.listif = kwargs.get('listif', False) return o
def testParseCodeArgs(self): x = _parse_codeargs(None) self.assertEqual({'args':[], 'kwargs':{}}, x) x = _parse_codeargs('abc') self.assertEqual({'args':['abc'], 'kwargs':{}}, x) x = _parse_codeargs('abc=5') self.assertEqual({'args':[], 'kwargs':{'abc':'5'}}, x) def testfn1(net): print() def testfn2(net, *args): print(args) def testfn3(net, *args, **kwargs): print(args, kwargs) def testfn5(net, *args, **kwargs): print(args, kwargs) with redirectio() as xio: with self.assertLogs(level='WARNING') as cm: _start_usercode(testfn1, None, _parse_codeargs('abc')) with redirectio() as xio: with self.assertLogs(level='WARNING') as cm: _start_usercode(testfn1, None, _parse_codeargs('abc efg=13')) with redirectio() as xio: with self.assertLogs(level='WARNING') as cm: _start_usercode(testfn1, None, _parse_codeargs('efg=13')) with redirectio() as xio: with self.assertLogs(level='WARNING') as cm: _start_usercode(testfn2, None, _parse_codeargs('efg=13')) with redirectio() as xio: _start_usercode(testfn5, None, _parse_codeargs('arg1 stararg1 stararg2 x=1 y=2')) self.assertEqual(xio.contents, "('arg1', 'stararg1', 'stararg2') {'x': '1', 'y': '2'}\n") with redirectio() as xio: _start_usercode(testfn2, None, _parse_codeargs('efg')) self.assertIn('efg', xio.contents) with redirectio() as xio: _start_usercode(testfn3, None, _parse_codeargs('efg')) self.assertIn('efg', xio.contents) with redirectio() as xio: _start_usercode(testfn3, None, _parse_codeargs('efg abc=42')) self.assertIn('efg', xio.contents) self.assertIn("'abc': '42'", xio.contents)