def dataProvider_testRuncmd(self): # 0: Normal yield testly.Data( cmd2run='ls', logs=['RUNNING: ls', '- PID', '- STDERR', '- RETURNCODE: 0']) # 1: Stderr yield testly.Data(cmd2run='echo 1 1>&2; echo 2 1>&2', logs=[ 'RUNNING: echo', '- PID:', '- STDERR: 1', '- STDERR: 2', '- RETURNCODE: 0' ]) # 2: Exception yield testly.Data(cmd2run='nosuchcmd', raised=True) # 3: Another rc yield testly.Data(cmd2run='exit 127', rc=127)
def getData(datafile=DATAFILE): with open(datafile) as stream: data = yaml.load(stream) for key, value in data.items(): kparts = key.split('.') tag = kparts[-1] if len(kparts) > 2 else 'default' proc = '.'.join(kparts[:2]) args = {'tag': tag} exptfiles = {} opt1 = {} opt2 = {} for k, v in value.items(): ret = args if k[:2] in ['i.', 'o.']: v = getioval(v, proc) if k[:2] == 'o.': k = k[2:] exptfiles[k] = v elif isinstance(v, list): args[k + ':list:one'] = v else: args[k] = v elif k.startswith('opt'): ret = opt1 if k.startswith('opt1.') else opt2 ret[k[5:]] = v else: ret[k] = v yield testly.Data(proc=proc, args=args, exptfiles=exptfiles, opt1=opt1, opt2=opt2)
def dataProvider_testCoerceValue(self): yield testly.Data('1', outval=1) yield testly.Data('1.1', outval=1.1) yield testly.Data('1.1E-2', outval=0.011) yield testly.Data('TRUE', outval=True) yield testly.Data('py:[1,2]', outval=[1, 2]) yield testly.Data(True, outval=True) yield '1', 'int', 1 yield '1.1', 'float', 1.1 yield 'False', 'bool', False yield True, 'str', 'True' yield 'a', 'int', None, ParameterTypeError yield '{"a":1}', 'py', {"a": 1} yield '1', 'list', [1] yield '1', 'list:str', ['1'] yield '1', 'list:bool', [True] yield 123, 'x', 123 yield 1, 'list:one', [[1]]
def dataProvider_testAddListFromFile(self): yield testly.Data(GENES_FILE.name, col = 1)
def dataProvider_testCmdargs(self): # 0: empty yield testly.Data(params={}, ret='') # 1: unexpected order yield testly.Data(params=dict(b=1, a=2), ret='-a 2 -b 1') # 2: keeping order yield testly.Data(params=OrderedDict([('b', 1), ('a', 2)]), ret='-b 1 -a 2') # 3: preceding positional arguments yield testly.Data(params={'': 'x', 'b': 1, 'a': 2}, ret='x -a 2 -b 1') # 4: ending positional arguments yield testly.Data(params={'_': 'x', 'b': 1, 'a': 2}, ret='-a 2 -b 1 x') # 5: write stdout to a file yield testly.Data(params={ '_': 'x', 'b': 1, 'a': 2, '_stdout': 'file' }, ret='-a 2 -b 1 x > file') # 6: append stdout to a file yield testly.Data(params={ '_': 'x', 'b': 1, 'a': 2, '__stdout': 'file' }, ret='-a 2 -b 1 x >> file') # 7: dash and equal yield testly.Data(params=OrderedDict([('b', 1), ('ac', 2)]), ret='-b 1 --ac=2') # 8: dash with '-' yield testly.Data(params=OrderedDict([('b', 1), ('ac', 2)]), dash='-', ret='-b 1 -ac=2') # 9: equal with ' ' yield testly.Data(params=OrderedDict([('b', 1), ('ac', 2)]), equal=' ', ret='-b 1 --ac 2') # 10: bools, ignorefalse = True yield testly.Data(params=dict(a=False, b=True), ignorefalse=True, ret='-b') # 11: bools, ignorefalse = False yield testly.Data(params=dict(a=False, b=True), ignorefalse=False, ret='-a 0 -b') # 12: list yield testly.Data(params=dict(a=[1, 2, 3]), duplistkey=False, ret='-a 1 2 3') # 13: list, duplistkey = True yield testly.Data(params=dict(a=[1, 2, 3]), duplistkey=True, ret='-a 1 -a 2 -a 3') # 14: multiple same keys yield testly.Data(params={ 'a': 1, 'a #1': 2, 'a #2': 3 }, ret='-a 1 -a 2 -a 3') # 15: quote yield testly.Data(params=dict(a='hello world', b='"'), ret='-a \'hello world\' -b \'"\'')