travic ci错误AttributeError:'module'对象没有属性'hashpw'

时间:2016-01-22 19:39:57

标签: python unit-testing continuous-integration travis-ci

我正在使用带有单元测试的travis ci。 测试在本地工作,但在travis ci中某种程度上失败了 这是日志的一部分。

======================================================================

ERROR: test_environment_is_development (test_config.TestConfigurations)

----------------------------------------------------------------------

Traceback (most recent call last):

  File "/home/travis/build/afaki077/minitweet/tests/base.py", line 17, in setUp

    self.create_user("admin", "ad@min.com", "adminpassword", confirmed=True)

  File "/home/travis/build/afaki077/minitweet/tests/base.py", line 33, in create_user

    u = User(name, email, password, bio, website, confirmed)

  File "<string>", line 4, in __init__

  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/sqlalchemy/orm/state.py", line 306, in _initialize_instance

    manager.dispatch.init_failure(self, args, kwargs)

  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__

    compat.reraise(exc_type, exc_value, exc_tb)

  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 183, in reraise

    raise value

  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/sqlalchemy/orm/state.py", line 303, in _initialize_instance

    return manager.original_init(*mixed[1:], **kwargs)

  File "/home/travis/build/afaki077/minitweet/minitweet_app/models.py", line 55, in __init__

    self.password = bcrypt.generate_password_hash(password)

  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/flask_bcrypt.py", line 163, in generate_password_hash

    return bcrypt.hashpw(password, bcrypt.gensalt(rounds))

AttributeError: 'module' object has no attribute 'hashpw'

也是travis不断告诉我我的测试通过了,虽然它没有

更新

我在本地做了一些测试,我用pip和运行测试删除了py-bcrypt模块我在travis上得到了同样的错误,当我重新安装它一切都很顺利。 (它仍然在travis ci上打破)

1 个答案:

答案 0 :(得分:1)

我解决了我的问题,问题是travis ci正在使用过时版本的pip 解决方案就是将其添加到.travis.yml

install: "pip install --upgrade pip && pip install -r requirements.txt"