test_config.py 文件源码

python
阅读 43 收藏 0 点赞 0 评论 0

项目:flask-zhenai-mongo-echarts 作者: Fretice 项目源码 文件源码
def test_uri_prioritised_over_host_and_port(self):
        self.app.config['MONGO_URI'] = 'mongodb://localhost:27017/database_name'
        self.app.config['MONGO_HOST'] = 'some_other_host'
        self.app.config['MONGO_PORT'] = 27018
        self.app.config['MONGO_DBNAME'] = 'not_the_correct_db_name'

        with warnings.catch_warnings():
            # URI connections without a username and password
            # work, but warn that auth should be supplied
            warnings.simplefilter('ignore')
            mongo = flask.ext.pymongo.PyMongo(self.app)
        if pymongo.version_tuple[0] > 2:
            time.sleep(0.2)
            assert ('localhost', 27017) == mongo.cx.address
        else:
            assert mongo.cx.host == 'localhost'
            assert mongo.cx.port == 27017
        assert mongo.db.name == 'database_name'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号