def test_telepath_basics(self): env = self.getFooEnv() foo = s_telepath.openlink(env.link) self.true(s_telepath.isProxy(foo)) self.false(s_telepath.isProxy(self)) # Test magic methods self.true(bool(foo) is True) self.true(foo == foo) self.false(foo == 1) self.true(foo != 1) s = time.time() for i in range(1000): foo.speed() e = time.time() self.eq(foo.bar(10, 20), 30) self.raises(NoSuchMeth, foo.faz, 10, 20) self.raises(SynErr, foo.baz, 10, 20) foo.fini() # We have fini'd the Proxy resources self.true(foo._tele_boss.isfini) self.true(foo._tele_sock.isfini) self.true(foo._tele_plex.isfini) env.fini()
def test_telepath_basics(self): env = self.getFooEnv() foo = s_telepath.openlink(env.link) self.true(s_telepath.isProxy(foo)) self.false(s_telepath.isProxy(self)) s = time.time() for i in range(1000): foo.speed() e = time.time() self.eq(foo.bar(10, 20), 30) self.raises(NoSuchMeth, foo.faz, 10, 20) self.raises(SynErr, foo.baz, 10, 20) foo.fini() env.fini()
def _loadDecoratedFuncs(self): for name, meth in s_reflect.getItemLocals(self): # Telepath will attempt to give you callable Method for any attr # you ask for which will end poorly for us when we try to call it if s_telepath.isProxy(meth): continue attr = getattr(meth, '_syn_config', None) if attr is None: continue self._syn_confs.append((attr, meth)) for attr, meth in self._syn_confs: if attr in self._syn_loaded_confs: continue self.addConfDefs(meth()) self._syn_loaded_confs.add(attr)