Django测试传递本地环境并在Travis CI上失败

时间:2017-08-17 04:23:59

标签: django travis-ci

我有以下项目结构

Project structure

当我运行./manage.py test时,结果为:

./manage.py test
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
..
----------------------------------------------------------------------
Ran 2 tests in 0.056s

OK
Destroying test database for alias 'default'...

但是当我向github推送时,Travis CI的构建会遇到错误的错误:

$ python manage.py test
.E
======================================================================
ERROR: test_import (core.tests.test_iodb.ImportTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/Sidon/work-at-olist/core/tests/test_iodb.py", line 14, in test_import
    channel = Channel.objects.get(name='Test1')
  File "/home/travis/virtualenv/python3.6.2/lib/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/travis/virtualenv/python3.6.2/lib/python3.6/site-packages/django/db/models/query.py", line 380, in get
    self.model._meta.object_name
core.models.DoesNotExist: Channel matching query does not exist.

在/home/travis/build/Sidon/work-at-olist/core/tests/test_iodb.py:

from core.models import Category, Channel
from core.utils import iocsv

class ImportTestCase(TestCase):
    categs1 = ....

    def test_import(self):
        iocsv.imp_categories('test1.csv', 'Test1')
   ===> channel = Channel.objects.get(name='Test1') # Here the error

0 个答案:

没有答案