【发布时间】:2016-01-13 15:01:48
【问题描述】:
我的本地系统中有一个结构文件,我用它在远程服务器(在 virtualenv 中)部署代码并想对其进行测试。方法定义如下。
def test_deploy(gitid = '930bfc4'):
# manually put the commit id at the end
path = '/tmp/testapp/app1/source/demo4'
with cd(path):
commit_id = 'git fetch https://myaccount@github.org/myaccount/demo4.git/heads/master:https://myaccount@github.org/myaccount/demo4.git/remotes/origin/master/'+gitid
# change the settings.py file and update the database
run (commit_id)
run ('cat .git/FETCH_HEAD')
path1 = '/tmp/testvehic/vehic'
with cd(path1):
run ('pwd')
env.activate = 'source /tmp/testapp/app1/bin/activate'
run ('python /tmp/testapp/app1/source/demo4/manage.py test')`
这表明
ImportError: 没有名为 django.core.management 的模块
在 Google 中进行一些搜索后,我知道它实际上并没有找到我的 django 环境。
我的虚拟环境路径是/tmp/testapp/app1
源代码在/tmp/testapp/app1/source/app1/
当我在服务器终端运行命令python manage.py test 时,它工作正常。如何通过织物进行测试?
【问题讨论】:
-
停止绑定激活东西,太多人弄错了,改为:
/tmp/testvehic/vehic/bin/python /tmp/testapp/app1/source/demo4/manage.py test它保证不会失败;没有人会看到代码而感到困惑;更容易调试;赢了! :P
标签: python django linux virtualenv fabric