我们travis.yml
看起来像这样:
language: python python: - "2.7" env: - "MONGO_URL=mongodb://localhost/" services: mongodb # command to install dependencies install: "pip install -r requirements.txt" # command to run tests script: nosetests
然后在带有测试的python脚本中,行
server.connect(os.environ['MONGO_URL'])
抛出错误(缩短):
File "/home/travis/virtualenv/python2.7/lib/python2.7/UserDict.py", line 23, in __getitem__ raise KeyError(key)
此错误仅发生在travis上.如果我们在本地运行它,它的工作没有问题.所以我们假设我们MONGO_URL
以错误的方式设置环境变量.我们已经尝试过省略引号,但它没有帮助.
任何提示?我们使用travis-ci的免费云服务.