运行测试覆盖Django项目时Travis-CI错误

时间:2015-10-03 15:20:15

标签: python django unit-testing code-coverage travis-ci

这是我第一次使用Travis-CI来检查我的项目。我是Django的新手。这个Django项目不是我的,我只是从另一个项目分叉。我想把.travis.yml用来检查项目的工作服。

但是我得到的错误让我对此毫无办法。我在谷歌找到答案,但我找不到它。

这是错误。

    $ coverage run manage.py test
nosetests --with-coverage --cover-erase --cover-html --cover-html-dir=xmlrunner/html --cover-inclusive --nocapture --nologcapture --verbosity=1
Creating test database for alias 'default'...
Traceback (most recent call last):
  File "/home/travis/virtualenv/python2.7.9/bin/coverage", line 9, in <module>
    load_entry_point('coverage==4.0', 'console_scripts', 'coverage')()
  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/coverage/cmdline.py", line 694, in main
    status = CoverageScript().command_line(argv)
  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/coverage/cmdline.py", line 435, in command_line
    return self.do_run(options, args)
  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/coverage/cmdline.py", line 577, in do_run
    self.coverage.stop()
  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/coverage/control.py", line 685, in stop
    self.collector.stop()
  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/coverage/collector.py", line 273, in stop
    "Expected current collector to be %r, but it's %r" % (self, self._collectors[-1])
AssertionError: Expected current collector to be <Collector at 0x7fc81bcd2350: CTracer>, but it's <Collector at 0x7fc809892710: CTracer>

这是我的.travis.yml

language: python

services:
  - postgresql

env:
  global:
    - DATABASE_URL='postgres://postgres:@localhost:5432/test_db'
    - SECRET_KEY='tT\xd7\xb06\xf7\x9b\xff\x0fZL\xca\xca\x11\xefM\xacr\xfb\xdf\xca\x9b'
    - DJANGO_SETTINGS_MODULE=core.settings.test_travis

python:
  - '2.7'

addons:
  postgresql: "9.3"

install:
  - pip install coveralls
  - pip install -r REQUIREMENTS.txt


before_script:
  - psql -c 'create database test_db;' -U postgres
  - psql -c 'CREATE EXTENSION postgis;' -U postgres -d test_db
  - cd django_project

script:
  - flake8
  - coverage run manage.py test

after_success:
  - coveralls

这是我的项目在Travis-CI https://travis-ci.org/rischanlab/projecta中的链接,这是我在Github的项目的链接https://github.com/rischanlab/projecta/

0 个答案:

没有答案