2014-02-19 51 views
0

我有一個Django項目與setup.py看起來像這樣:coverage.py和setup.py和Django的測試

. 
├── backend 
├── backoffice 
├── backoffice_set 
├── manage.py 
├── MANIFEST.in 
├── media 
├── README.rst 
├── requirements.txt 
├── setup.py 
└── venv2.7 

當我運行:python setup.py test一切正常但是,當我運行:

/opt/bin/coverage run setup.py test 

測試失敗:

writing dependency_links to cfe_backoffice.egg-info/dependency_links.txt 
reading manifest template 'MANIFEST.in' 
warning: no files found matching '*' under directory 'backoffice/templates/backoffice/' 
writing manifest file 'cfe_backoffice.egg-info/SOURCES.txt' 
running build_ext 
Traceback (most recent call last): 
    File "setup.py", line 21, in <module> 
    setup(
    File "/opt/lib/python2.7/distutils/core.py", line 152, in setup 
    dist.run_commands() 
    File "/opt/lib/python2.7/distutils/dist.py", line 953, in run_commands 
    self.run_command(cmd) 
    File "/opt/lib/python2.7/distutils/dist.py", line 972, in run_command 
    cmd_obj.run() 
    File "build/bdist.linux-i686/egg/setuptools/command/test.py", line 138, in run 
    self.with_project_on_sys_path(self.run_tests) 
    File "build/bdist.linux-i686/egg/setuptools/command/test.py", line 118, in with_project_on_sys_path 
    func() 
    File "build/bdist.linux-i686/egg/setuptools/command/test.py", line 164, in run_tests 
    testLoader = cks 
    File "/opt/lib/python2.7/unittest/main.py", line 94, in __init__ 
    self.parseArgs(argv) 
    File "/opt/lib/python2.7/unittest/main.py", line 149, in parseArgs 
    self.createTests() 
    File "/opt/lib/python2.7/unittest/main.py", line 158, in createTests 
    self.module) 
    File "/opt/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames 
    suites = [self.loadTestsFromName(name, module) for name in names] 
    File "/opt/lib/python2.7/unittest/loader.py", line 100, in loadTestsFromName 
    parent, obj = obj, getattr(obj, part) 
AttributeError: 'module' object has no attribute 'runtests' 

有沒有人見過這個?你能提出一個解決方案嗎?

回答

1

好吧,過了一段時間,我找到了解決方案。 Django沒有安裝在全球,這正是我想要的。

我創建了虛擬環境:

virtualenv --enable-system-packages 

所以這導致coverage.py沒有安裝我virtualenv內。因此,解決方案,這是強制pip-I安裝它,這裏是行動的完整日誌:

/opt/bin/virtualenv --system-site-packages venv2.7 
. venv2.7/bin/activate 
pip install -r requirements.txt 
pip install -I coverage 
coverage run setup.py test