def test_delegator_is_separate_object(): d = Delegatee() a = Delegator(d) a.delegator_method = lambda: 10 assert 'delegator_method' not in dir(d) assert 'delegator_method' in dir(a)
def _delegate(self, event, obj, *args, **kwargs): """ Process a single event by dispatching the event to the best-fitting event-handler. If an event-handler is not available, return None otherwise return the result of the processing. """ self.log.debug('Process event, ' + str(event()) + '.') function = Delegator.get_handler(obj, event) if function: self.log.info('Dispatching event, ' + str(event()) + ', to function, ' + str(function.__name__) + '.') return function(event, *args, **kwargs) else: self.log.debug('Unhandled event, ' + str(event()) + '.') return None
def POST(self): # Json from github payload = web.data() print print 'DATA RECEIVED:' print payload # send payload to delegator delegator = Delegator(payload) print 'DELEGATOR PARSED' if delegator.action: print 'REPO FOUND' man = Manager(delegator.action) print 'RUNNING CMDS' man.do() print 'DELEGATOR FOUND NO ACTION' return 'OK'
_s = recursive_import.myClass() assert str(_s) == "success!" import from_import_test.b assert from_import_test.b.v == 1 import from_import_test.c assert from_import_test.c.v == 1 # test of keyword "global" in functions of an imported module import global_in_imported assert global_in_imported.X == 15 from delegator import Delegator delegate = Delegator([]) # test VFS path entry finder and from <module> import * import sys # Ensure that VFS path finder is installed from _importlib import VFSPathFinder if VFSPathFinder not in sys.path_hooks: sys.path_hooks.insert(0, VFSPathFinder) print('WARNING: VFS path hook installed') else: print('INFO: VFS path finder already installed') print('Testing VFS for .py files') # Add VFS file URL at the beginning of import search path vfs_url = __BRYTHON__.brython_path + '../tests/test.vfs.js'
def test_delegator_has_access_in_constructor(): d = Delegatee() a = Delegator(d, bar=lambda self: self.foo() + 5) assert a.bar() == 15
def test_delegator_can_override(): d = Delegatee() a = Delegator(d, foo=lambda self: 5) assert a.foo() == 5
def test_delegator_passes_through(): d = Delegatee() a = Delegator(d) assert a.foo() == 10