Beispiel #1
0
	def testFuncSig (self):
		def func1 ():
			pass
		
		func2 = lambda x: x
		func3 = ""
		self.assertEqual (utils.funcsig(func1).strip(), "def func1 ():\n\t\t\tpass")
		self.assertEqual (utils.funcsig(func2).strip(), "func2 = lambda x: x")
		self.assertEqual (utils.funcsig(func3), "None")
Beispiel #2
0
    def testSuffix(self):
        p = proc('tag_unique')
        config = {
            key: val
            for key, val in p.config.iteritems() if key not in [
                'workdir', 'forks', 'cache', 'retcodes', 'echo', 'runner',
                'exportdir', 'exporthow', 'exportow', 'errorhow', 'errorntry'
            ] or key.endswith('Runner')
        }
        config['id'] = p.id
        config['tag'] = p.tag
        if config.has_key('callback'):
            config['callback'] = utils.funcsig(config['callback'])
        # proc is not picklable
        if config.has_key('depends'):
            depends = config['depends']
            pickable_depends = []
            if isinstance(depends, proc):
                depends = [depends]
            elif isinstance(depends, aggr):
                depends = depends.procs
            for depend in depends:
                pickable_depends.append(depend.id + '.' + depend.tag)
            config['depends'] = pickable_depends

        if config.has_key('input') and isinstance(config['input'], dict):
            config['input'] = copy.deepcopy(config['input'])
            for key, val in config['input'].iteritems():
                config['input'][key] = utils.funcSig(val) if callable(
                    val) else val

        signature = pickle.dumps(str(config))
        self.assertEqual(p._suffix(), utils.uid(signature))
Beispiel #3
0
	def dataProvider_testSuffix(self):
		pSuffix = Proc()
		pSuffix.props['suffix'] = '23lhsaf'
		yield pSuffix, '23lhsaf'
		
		pSuffix1 = Proc()
		pSuffix1.input = {'in': lambda ch: ch}
		pSuffix1.depends = pSuffix
		config = {key:val for key, val in pSuffix1.config.items() if key in [
			'id', 'tag', 'input'
		]}
		config['argv0'] = path.realpath(sys.argv[0])
		if isinstance(config['input'], dict):
			config['input'] = pycopy.copy(config['input'])
			for key, val in config['input'].items():
				config['input'][key] = utils.funcsig(val) if callable(val) else val
		config['depends'] = [pSuffix.name(True) + '#' + pSuffix._suffix()]
		yield pSuffix1, utils.uid(json.dumps(config, sort_keys = True))
Beispiel #4
0
def test_funcsig(fixt_funcsig):
    assert funcsig(fixt_funcsig.func) == fixt_funcsig.expt