def reset(): ''' Reset the stack to its initial state For testing purposes ''' s_task.varset('provstack', _ProvStack())
async def test_taskvars(self): s_task.varset('test', 'foo') self.eq(s_task.varget('test'), 'foo') self.none(s_task.varget('nope')) s_task.vardefault('test2', lambda: [1, 2, 3]) test2 = s_task.varget('test2') self.eq(test2, [1, 2, 3]) test2.append(4) self.eq([1, 2, 3, 4], s_task.varget('test2')) async def taskfunc(): self.none(s_task.varget('test')) self.eq([1, 2, 3], s_task.varget('test2')) s_task.varset('test', 42) await asyncio.create_task(taskfunc()) self.eq(s_task.varget('test'), 'foo')
async def taskfunc(): self.none(s_task.varget('test')) self.eq([1, 2, 3], s_task.varget('test2')) s_task.varset('test', 42)
def dupstack(newtask): ''' Duplicate the current provenance stack onto another task ''' stack = s_task.varget('provstack') s_task.varset('provstack', stack.copy(), newtask)