from twisted.protocols import wire, basic from twisted.internet import protocol, reactor import copy, os, pickle, sys, warnings try: from twisted.web import microdom gotMicrodom = True except ImportError: import warnings warnings.warn("Not testing xml persistence as twisted.web.microdom " "not available") gotMicrodom = False suppressOldApp = lambda x : util.suppressWarnings(x, ('twisted.internet.app is deprecated', DeprecationWarning)) class Dummy: processName=None class TestService(unittest.TestCase): def testName(self): s = service.Service() s.setName("hello") self.failUnlessEqual(s.name, "hello") def testParent(self): s = service.Service() p = service.MultiService()
movedModules = [('twisted.protocols.smtp', 'twisted.mail.smtp'), ('twisted.protocols.imap4', 'twisted.mail.imap4'), ('twisted.protocols.pop3', 'twisted.mail.pop3'), ('twisted.protocols.dns', 'twisted.names.dns'), ('twisted.protocols.ethernet', 'twisted.pair.ethernet'), ('twisted.protocols.raw', 'twisted.pair.raw'), ('twisted.protocols.rawudp', 'twisted.pair.rawudp'), ('twisted.protocols.ip', 'twisted.pair.ip'), ('twisted.protocols.irc', 'twisted.words.protocols.irc'), ('twisted.protocols.msn', 'twisted.words.protocols.msn'), ('twisted.protocols.toc', 'twisted.words.protocols.toc'), ('twisted.protocols.oscar', 'twisted.words.protocols.oscar'), ] class TestCompatibility(unittest.TestCase): def testCompatibility(self): for oldName, newName in movedModules: try: old = reflect.namedModule(oldName) new = reflect.namedModule(newName) except ImportError, e: continue for someName in [x for x in vars(new).keys() if x != '__doc__']: self.assertIdentical(getattr(old, someName), getattr(new, someName)) testCompatibility = util.suppressWarnings(testCompatibility, ('', DeprecationWarning))
auth.addIdentity(ident) svr = pb.BrokerFactory(pb.AuthRoot(auth)) s = svr.buildProtocol(('127.0.0.1',)) s.copyTags = {} cio = StringIO() sio = StringIO() c.makeConnection(protocol.FileWrapper(cio)) s.makeConnection(protocol.FileWrapper(sio)) pump = IOPump(c, s, cio, sio) # Challenge-response authentication: pump.flush() return c, s, pump connectedServerAndClient = suppressWarnings(connectedServerAndClient, ("twisted.internet.app", DeprecationWarning), ("Identities", DeprecationWarning), ("Cred services", DeprecationWarning), ("This is deprecated. Use PBServerFactory.", DeprecationWarning), ("Authorizers are deprecated, switch to portals/realms/etc.", DeprecationWarning)) class SimpleRemote(pb.Referenceable): def remote_thunk(self, arg): self.arg = arg return arg + 1 def remote_knuth(self, arg): raise Exception() class NestedRemote(pb.Referenceable): def remote_getSimple(self): return SimpleRemote() class SimpleCopy(pb.Copyable):