本文整理汇总了Python中twistedcaldav.test.util.TestCase类的典型用法代码示例。如果您正苦于以下问题:Python TestCase类的具体用法?Python TestCase怎么用?Python TestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestCase类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
TestCase.setUp(self)
self.notifier = StubNotifier()
self.protocol = SimpleLineNotificationProtocol()
self.protocol.notifier = self.notifier
self.protocol.transport = StubTransport()
self.notifier.addObserver(self.protocol)
示例2: setUp
def setUp(self):
"""
Create a L{MemCachePool}.
"""
TestCase.setUp(self)
self.reactor = StubReactor()
self.pool = MemCachePool(MC_ADDRESS,
maxClients=5,
reactor=self.reactor)
示例3: setUp
def setUp(self):
TestCase.setUp(self)
self.memcache = InMemoryMemcacheProtocol()
self.ccn = MemcacheChangeNotifier(
StubURLResource(':memory:'),
cachePool=self.memcache)
self.ccn._newCacheToken = instancemethod(_newCacheToken,
self.ccn,
MemcacheChangeNotifier)
示例4: setUp
def setUp(self):
"""
Set up our options object, giving it a parent, and forcing the
global config to be loaded from defaults.
"""
TestCase.setUp(self)
self.config = TestCalDAVOptions()
self.config.parent = Options()
self.config.parent["uid"] = 0
self.config.parent["gid"] = 0
self.config.parent["nodaemon"] = False
示例5: setUp
def setUp(self):
TestCase.setUp(self)
self.options = TestCalDAVOptions()
self.options.parent = Options()
self.options.parent["gid"] = None
self.options.parent["uid"] = None
self.options.parent["nodaemon"] = None
self.config = ConfigDict(DEFAULT_CONFIG)
accountsFile = os.path.join(sourceRoot, "twistedcaldav/directory/test/accounts.xml")
resourcesFile = os.path.join(sourceRoot, "twistedcaldav/directory/test/resources.xml")
augmentsFile = os.path.join(sourceRoot, "twistedcaldav/directory/test/augments.xml")
pemFile = os.path.join(sourceRoot, "twistedcaldav/test/data/server.pem")
self.config["DirectoryService"] = {
"params": {"xmlFile": accountsFile},
"type": "twistedcaldav.directory.xmlfile.XMLDirectoryService"
}
self.config["ResourceService"] = {
"params": {"xmlFile": resourcesFile},
}
self.config["AugmentService"] = {
"params": {"xmlFiles": [augmentsFile]},
"type": "twistedcaldav.directory.augment.AugmentXMLDB"
}
self.config.UseDatabase = False
self.config.ServerRoot = self.mktemp()
self.config.ConfigRoot = "config"
self.config.ProcessType = "Single"
self.config.SSLPrivateKey = pemFile
self.config.SSLCertificate = pemFile
self.config.EnableSSL = True
self.config.Memcached.Pools.Default.ClientEnabled = False
self.config.Memcached.Pools.Default.ServerEnabled = False
self.config.DirectoryAddressBook.Enabled = False
self.config.SudoersFile = ""
if self.configOptions:
self.config.update(self.configOptions)
os.mkdir(self.config.ServerRoot)
os.mkdir(os.path.join(self.config.ServerRoot, self.config.DocumentRoot))
os.mkdir(os.path.join(self.config.ServerRoot, self.config.DataRoot))
os.mkdir(os.path.join(self.config.ServerRoot, self.config.ConfigRoot))
self.configFile = self.mktemp()
self.writeConfig()
示例6: setUp
def setUp(self):
"""
Create a memcache client, connect it to a string protocol, and make it
use a deterministic clock.
"""
TestCase.setUp(self)
self.proto = MemCacheProtocol()
self.clock = Clock()
self.proto.callLater = self.clock.callLater
self.transport = StringTransportWithDisconnection()
self.transport.protocol = self.proto
self.proto.makeConnection(self.transport)
示例7: setUp
def setUp(self):
"""
Create a L{MemCachePool}.
"""
TestCase.setUp(self)
self.reactor = StubReactor()
self.pool = MemCachePool(
TCP4ClientEndpoint(self.reactor, MC_ADDRESS.host, MC_ADDRESS.port),
maxClients=5, reactor=self.reactor
)
realClientFactory = self.pool.clientFactory
self.clientFactories = []
def capturingClientFactory(*a, **k):
cf = realClientFactory(*a, **k)
self.clientFactories.append(cf)
return cf
self.pool.clientFactory = capturingClientFactory
示例8: setUp
def setUp(self):
"""
Create a DigestCredentialFactory for testing
"""
TestCase.setUp(self)
config.ProcessType = "Single"
self.namespace1 = "DIGEST1"
self.namespace2 = "DIGEST2"
self.credentialFactories = (QopDigestCredentialFactory(
'md5',
'auth',
'test realm',
self.namespace1
),
QopDigestCredentialFactory(
'md5',
'',
'test realm',
self.namespace2
))
示例9: setUp
def setUp(self):
"""
Set up our options object, giving it a parent, and forcing the
global config to be loaded from defaults.
"""
TestCase.setUp(self)
self.options = CalDAVTaskOptions()
self.options.parent = Options()
self.options.parent["uid"] = 0
self.options.parent["gid"] = 0
self.options.parent["nodaemon"] = False
self.config = ConfigDict(DEFAULT_CONFIG)
accountsFile = os.path.join(sourceRoot, "twistedcaldav/directory/test/accounts.xml")
self.config["DirectoryService"] = {
"params": {"xmlFile": accountsFile},
"type": "twistedcaldav.directory.xmlfile.XMLDirectoryService"
}
self.config.DocumentRoot = self.mktemp()
self.config.DataRoot = self.mktemp()
self.config.ProcessType = "Single"
self.config.Memcached.ClientEnabled = False
self.config.Memcached.ServerEnabled = False
pemFile = os.path.join(sourceRoot, "twistedcaldav/test/data/server.pem")
self.config.SSLPrivateKey = pemFile
self.config.SSLCertificate = pemFile
os.mkdir(self.config.DocumentRoot)
os.mkdir(self.config.DataRoot)
self.configFile = self.mktemp()
self.writeConfig()
示例10: setUp
def setUp(self):
TestCase.setUp(self)
self.resource = CalDAVResource()
self.resource._dead_properties = InMemoryPropertyStore()
示例11: setUp
def setUp(self):
TestCase.setUp(self)
self.handler = MailHandler(dataRoot=":memory:")
self.dataDir = os.path.join(os.path.dirname(__file__), "data", "mail")
示例12: setUp
def setUp(self):
TestCase.setUp(self)
config.setProvider(PListConfigProvider(DEFAULT_CONFIG))
self.testConfig = self.mktemp()
open(self.testConfig, "w").write(testConfig)