Travis 上的奇怪构建错误,tox 工作中的本地测试

Strange build error on Travis, local tests in tox work

我在 Travis 上遇到一个奇怪的错误,https://travis-ci.org/edoburu/django-fluent-blogs 的构建在 Django 1.7 和更低版本中失败:

from django.utils.six import python_2_unicode_compatible

ImportError: cannot import name 'python_2_unicode_compatible'

这对于构建测试所针对的每个 Django 版本都是可导入的,并且不知何故只适用于 Django 1.8。 运行 使用 tox 进行本地测试。

知道为什么会这样吗?

试试 django.utils.encoding:

from django.utils.encoding import python_2_unicode_compatible