本文整理汇总了Python中pymongo.connection.Connection.host方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.host方法的具体用法?Python Connection.host怎么用?Python Connection.host使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymongo.connection.Connection
的用法示例。
在下文中一共展示了Connection.host方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_deprecated_method_for_attr
# 需要导入模块: from pymongo.connection import Connection [as 别名]
# 或者: from pymongo.connection.Connection import host [as 别名]
def test_deprecated_method_for_attr(self):
c = Connection(self.host, self.port)
db = c.foo
coll = db.bar
warnings.simplefilter("error")
self.assertRaises(DeprecationWarning, c.host)
self.assertRaises(DeprecationWarning, c.port)
self.assertRaises(DeprecationWarning, db.connection)
self.assertRaises(DeprecationWarning, db.name)
self.assertRaises(DeprecationWarning, coll.full_name)
self.assertRaises(DeprecationWarning, coll.name)
self.assertRaises(DeprecationWarning, coll.database)
warnings.resetwarnings()
warnings.simplefilter("ignore")
self.assertEqual(c.host, c.host())
self.assertEqual(c.port, c.port())
self.assertEqual(db.connection, db.connection())
self.assertEqual(db.name, db.name())
self.assertEqual(coll.full_name, coll.full_name())
self.assertEqual(coll.name, coll.name())
self.assertEqual(coll.database, coll.database())
warnings.resetwarnings()
warnings.simplefilter("default")
self.assertEqual(self.host, c.host)
self.assertEqual(self.port, c.port)
self.assertEqual(c, db.connection)
self.assertEqual("foo", db.name)
self.assertEqual("foo.bar", coll.full_name)
self.assertEqual("bar", coll.name)
self.assertEqual(db, coll.database)