0

我有一个依赖 BeautifSoup https://github.com/fgregg/legistar-scrape的小型 python 网络爬虫。我的测试在本地运行良好,但是在 travis-ci 上,nosetests 立即出错,因为它找不到 BeautifulSoup,它看起来像是刚刚完成安装。

Travis-CI 构建日志在这里:https ://travis-ci.org/fgregg/legistar-scrape/jobs/5628189

有什么建议么?

4

1 回答 1

1

推荐

改变这个

install: "sudo pip install -r requirements.txt"

对此:

install: "pip install -r requirements.txt"

在这里查看使用情况。

概念证明

我 fork 你的 github 项目,将我的 fork 添加到我的 travis-ci 帐户,做出我建议的更改,提交并推送到 github。这里有两个成功的 travis-ci 构建:python 2.6python 2.7

虚拟环境

您是否使用virtualenv进行 Python 开发?还是在sudo pip install -r requirements.txt本地运行时使用?我建议您查看 virtualenvs 并停止使用sudo pip install. 这就是当今大多数 Python 开发人员所做的。这就是 travis-ci 的工作原理:它创建一个 virtualenv 并从中运行您的应用程序。

鼻测

Separately, your nosetests are really slow because you are integration testing -- you are hitting live servers across the internet, right? Look up how to use the mock library so that you mock the HTML returned from your URLs instead of actually hitting those servers.

于 2013-03-19T16:51:12.860 回答