def e(): yield results.append(local('_x_')) yield results.append(local('_y_')) yield results.append(local('_z_'))
def testVariousTypes(self): strArgument = 'string' self.assertEquals('string', local('strArgument')) intArgument = 1 self.assertEquals(1, local('intArgument')) class MyObject(object): pass objArgument = MyObject() self.assertEquals(objArgument, local('objArgument'))
def testOne(self): a=1 b=2 c=3 def f1(): d=4 a=10 b=6 self.assertEquals(4, local('d')) self.assertEquals(10, local('a')) f1() self.assertEquals(2, local('b')) self.assertEquals(1, local('a'))
def testOne(self): a = 1 b = 2 c = 3 def f1(): d = 4 a = 10 b = 6 self.assertEquals(4, local('d')) self.assertEquals(10, local('a')) f1() self.assertEquals(2, local('b')) self.assertEquals(1, local('a'))
def do_unknown(self, message, *args, **kwargs): myLogCollector = local("__callstack_var_logCollector__") try: __callstack_var_logCollector__ = LogCollector._logCollector() self.do.unknown(message, *args, **kwargs) finally: myLogCollector[self._scopeName] = __callstack_var_logCollector__
def testNotFound(self): try: v = local('no_such_thing') print "V", v self.fail() except AttributeError: pass
def do_unknown(self, message, *args, **kwargs): myLogCollector = local('__callstack_var_logCollector__') try: __callstack_var_logCollector__ = LogCollector._logCollector() self.do.unknown(message, *args, **kwargs) finally: myLogCollector[self._scopeName] = __callstack_var_logCollector__
def timeAfterFinished(): assert local('__reactor__') is reactor() # Code explaining code :-) currentReactor = reactor() currentReactor.addTimer(1.0, lambda: neverCalled.append(True)) yield 'async work...' currentReactor.addProcess(lambda: neverCalled.append(True)) raise StopIteration(42)
def timeAfterFinished(): assert local( '__reactor__') is reactor() # Code explaining code :-) currentReactor = reactor() currentReactor.addTimer(1.0, lambda: neverCalled.append(True)) yield 'async work...' currentReactor.addProcess(lambda: neverCalled.append(True)) raise StopIteration(42)
def all_unknown(self, message, *args, **kwargs): try: __callstack_dict__ = local('__callstack_dict__') except AttributeError: __callstack_dict__ = {} for key, valueFunction in self._keyValueFunctions.items(): __callstack_dict__[key] = valueFunction(**kwargs) yield self.all.unknown(message, *args, **kwargs)
def call_unknown(self, message, *args, **kwargs): myLogCollector = local("__callstack_var_logCollector__") try: __callstack_var_logCollector__ = LogCollector._logCollector() try: return self.call.unknown(message, *args, **kwargs) except NoneOfTheObserversRespond: raise DeclineMessage finally: myLogCollector[self._scopeName] = __callstack_var_logCollector__
def callStackDictGet(key, *args, **kwargs): try: d = local('__callstack_dict__') return d[key] except (AttributeError, KeyError): if args or 'default' in kwargs: default = args[0] if args else kwargs['default'] return default else: raise
def call_unknown(self, message, *args, **kwargs): myLogCollector = local('__callstack_var_logCollector__') try: __callstack_var_logCollector__ = LogCollector._logCollector() try: return self.call.unknown(message, *args, **kwargs) except NoneOfTheObserversRespond: raise DeclineMessage finally: myLogCollector[self._scopeName] = __callstack_var_logCollector__
def any_unknown(self, message, *args, **kwargs): myLogCollector = local('__callstack_var_logCollector__') try: __callstack_var_logCollector__ = LogCollector._logCollector() try: response = yield self.any.unknown(message, *args, **kwargs) except NoneOfTheObserversRespond: raise DeclineMessage raise StopIteration(response) finally: myLogCollector[self._scopeName] = __callstack_var_logCollector__
def any_unknown(self, message, *args, **kwargs): myLogCollector = local("__callstack_var_logCollector__") try: __callstack_var_logCollector__ = LogCollector._logCollector() try: response = yield self.any.unknown(message, *args, **kwargs) except NoneOfTheObserversRespond: raise DeclineMessage raise StopIteration(response) finally: myLogCollector[self._scopeName] = __callstack_var_logCollector__
def testLookupSelfWhileBeingInitialized(self): try: tx = local('tx') self.fail() except AttributeError: pass
def addMethod(**kwargs): listRequests.append(local('__callstack_var_oaiListRequest__')) return yield
def collectLog(*logDicts): collector=local('__callstack_var_logCollector__') for aLogDict in logDicts: for key, value in aLogDict.items(): collector.setdefault(key, []).append(value)
def f(self): v = local("aLocal") yield v
def f1(): d=4 a=10 b=6 self.assertEquals(4, local('d')) self.assertEquals(10, local('a'))
def function(): toplevel=MyObject() refs.append(local('toplevel'))
def __init__(self, timeout): self.gio = local('__gio__') self._timeout = timeout self._timer = None
def __enter__(self): self.gio = local('__gio__') self.gio.pushContext(self) return self
def __getattr__(self, name): try: return local('__callstack_var_%s__' % name) except AttributeError: raise AttributeError("'%s' has no attribute '%s'" % (self, name))
def testNone(self): var = None self.assertEquals(None, local('var'))
def c(): yield local('no_such_thing')
def log(self, **kwargs): try: _log(local('__callstack_var_statisticsLog__'), **kwargs) except AttributeError: pass
def testScope(self): _some_var_on_the_callstack_ = 'aap' v = local('_some_var_on_the_callstack_') self.assertEquals('aap', v)
def f1(): d = 4 a = 10 b = 6 self.assertEquals(4, local('d')) self.assertEquals(10, local('a'))
def function(): toplevel = MyObject() refs.append(local('toplevel'))
def collectLogForScope(**scopes): for scope, aLogDict in scopes.items(): collector=local('__callstack_var_logCollector__').setdefault(scope, dict()) for key, value in aLogDict.items(): collector.setdefault(key, []).append(value)
def collectLog(*logDicts): collector = local("__callstack_var_logCollector__") for aLogDict in logDicts: for key, value in aLogDict.items(): collector.setdefault(key, []).append(value)
def collectLogForScope(**scopes): for scope, aLogDict in scopes.items(): collector = local("__callstack_var_logCollector__").setdefault(scope, dict()) for key, value in aLogDict.items(): collector.setdefault(key, []).append(value)
def reactor(): return local('__reactor__')
def b(): local('no_such_thing')
def h(): tx_id = local("tx_id") #2 print tx_id