本文整理汇总了Python中test.utils.assertRaisesExactly函数的典型用法代码示例。如果您正苦于以下问题:Python assertRaisesExactly函数的具体用法?Python assertRaisesExactly怎么用?Python assertRaisesExactly使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assertRaisesExactly函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_lazy_auth_raises_operation_failure
def test_lazy_auth_raises_operation_failure(self):
lazy_client = MongoClient(
"mongodb://user:[email protected]%s:%d/pymongo_test" % (host, port),
_connect=False)
assertRaisesExactly(
OperationFailure, lazy_client.test.collection.find_one)
示例2: test_connect
def test_connect(self):
assertRaisesExactly(ConnectionFailure, MongoReplicaSetClient,
"somedomainthatdoesntexist.org:27017",
replicaSet=self.name,
connectTimeoutMS=600)
self.assertRaises(ConfigurationError, MongoReplicaSetClient,
pair, replicaSet='fdlksjfdslkjfd')
self.assertTrue(MongoReplicaSetClient(pair, replicaSet=self.name))
示例3: test_connect
def test_connect(self):
# Check that the exception is a ConnectionFailure, not a subclass like
# AutoReconnect
assertRaisesExactly(ConnectionFailure, MongoClient, "somedomainthatdoesntexist.org", connectTimeoutMS=600)
assertRaisesExactly(ConnectionFailure, MongoClient, host, 123456789)
self.assertTrue(MongoClient(host, port))
示例4: test_lazy_auth_raises_operation_failure
def test_lazy_auth_raises_operation_failure(self):
# Check if we have the prerequisites to run this test.
c = self._get_client()
if not server_started_with_auth(c):
raise SkipTest("Authentication is not enabled on server")
lazy_client = MongoReplicaSetClient(
"mongodb://user:[email protected]%s/pymongo_test" % pair, replicaSet=self.name, _connect=False
)
assertRaisesExactly(OperationFailure, lazy_client.test.collection.find_one)
示例5: test_connect_with_internal_ips
def test_connect_with_internal_ips(self):
# Client is passed an IP it can reach, 'a:1', but the RS config
# only contains unreachable IPs like 'internal-ip'. PYTHON-608.
assertRaisesExactly(
ConnectionFailure,
MockReplicaSetClient,
standalones=[],
members=['a:1'],
mongoses=[],
ismaster_hosts=['internal-ip:27017'],
host='a:1',
replicaSet='rs')
示例6: test_lazy_auth_raises_operation_failure
def test_lazy_auth_raises_operation_failure(self):
# Check if we have the prerequisites to run this test.
c = MongoClient(host, port)
if not server_started_with_auth(c):
raise SkipTest("Authentication is not enabled on server")
if is_mongos(c) and not version.at_least(c, (2, 0, 0)):
raise SkipTest("Auth with sharding requires MongoDB >= 2.0.0")
lazy_client = MongoClient("mongodb://user:[email protected]%s:%d/pymongo_test" % (host, port), _connect=False)
assertRaisesExactly(OperationFailure, lazy_client.test.collection.find_one)
示例7: test_constants
def test_constants(self):
Connection.HOST = self.host
Connection.PORT = self.port
self.assertTrue(Connection())
Connection.HOST = "somedomainthatdoesntexist.org"
Connection.PORT = 123456789
assertRaisesExactly(ConnectionFailure, Connection, connectTimeoutMS=600)
self.assertTrue(Connection(self.host, self.port))
Connection.HOST = self.host
Connection.PORT = self.port
self.assertTrue(Connection())
示例8: test_constants
def test_constants(self):
MongoClient.HOST = host
MongoClient.PORT = port
self.assertTrue(MongoClient())
MongoClient.HOST = "somedomainthatdoesntexist.org"
MongoClient.PORT = 123456789
assertRaisesExactly(ConnectionFailure, MongoClient, connectTimeoutMS=600)
self.assertTrue(MongoClient(host, port))
MongoClient.HOST = host
MongoClient.PORT = port
self.assertTrue(MongoClient())
示例9: test_connect
def test_connect(self):
# Check that the exception is a ConnectionFailure, not a subclass like
# AutoReconnect
assertRaisesExactly(
ConnectionFailure, MongoClient,
"somedomainthatdoesntexist.org", connectTimeoutMS=600)
assertRaisesExactly(
ConnectionFailure, MongoClient, host, 123456789)
self.assertTrue(MongoClient(host, port))
# Test that connect=False prevents the constructor from raising
# ConnectionFailure.
client = MongoClient("somedomainthatdoesnotexist.org",
connectTimeoutMS=100, connect=False)
try:
client.admin.command("ismaster")
except AutoReconnect:
pass
示例10: test_host_w_port
def test_host_w_port(self):
self.assertTrue(Connection("%s:%d" % (self.host, self.port)))
assertRaisesExactly(ConnectionFailure, Connection,
"%s:1234567" % (self.host,), self.port)
示例11: test_lazy_auth_raises_operation_failure
def test_lazy_auth_raises_operation_failure(self):
lazy_client = rs_or_single_client(
"mongodb://user:[email protected]%s/pymongo_test" % host, connect=False)
assertRaisesExactly(
OperationFailure, lazy_client.test.collection.find_one)
示例12: test_host_w_port
def test_host_w_port(self):
self.assertTrue(MongoClient("%s:%d" % (host, port)))
assertRaisesExactly(
ConnectionFailure, MongoClient, "%s:1234567" % (host,), port)