在使用 CI 服务器上自动测试 python 项目期间发生此错误pytest
.我正在使用pytest==4.0.2
.此错误才刚刚开始发生,以前的管道似乎工作正常。
完整错误:
File "/usr/local/lib/python3.7/site-packages/_pytest/tmpdir.py", line 35, in TempPathFactory
lambda p: Path(os.path.abspath(six.text_type(p)))
TypeError: attrib() got an unexpected keyword argument 'convert'
pytest
似乎将包attrs
作为依赖项。attrs==19.2.0
在2019-10-01 17:00 UTC
左右发布。这似乎导致了上面的问题。
切换回attrs==19.1.0
可以解决问题。只需执行以下操作:
pip install attrs==19.1.0
注意:我希望通过发布新版本attrs
或很快pytest
解决这个问题。因此,此修复程序应该只是暂时的。
从评论中:此错误不会发生在较新版本的pytest上,即pytest==5.2.0
pytest 使用已弃用的关键字convert
在 3.6.3 (https://docs.pytest.org/en/latest/changelog.html#pytest-3-6-3-2018-07-04( 中修复。 在 4.0.1 中,pytest 使用convert
(https://github.com/pytest-dev/pytest/pull/4427( 合并了代码。 此代码已在 5.2.0 (https://github.com/pytest-dev/pytest/pull/4795( 上修复。
pytest 版本 5.3.1 和 attrs 版本 19.3.0 对我来说效果很好。 [要检查 pytest 版本和 attrs 版本,请发出以下命令:]
pip show pytest attrs
我通过 pip 命令升级 pytest 模块解决了同样的问题:
pip install -U pytest
python -m pip install --upgrade pytest
(蟒蛇提示符或CMD(
这应该可以解决您的问题,因为 pytest 的更新版本会自动处理 ATTR 问题。
我在 v2aws-encryption-cli
也有同样的错误。 我已经更新了我的aws-cdk.core
库,它可以再次迁移到 V2aws-encryption-cli
。
pip install -U aws-cdk.core
V2 文档:https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/crypto-cli-examples.html#cli-example-encrypt-file
GitHub 错误:https://github.com/aws/aws-cdk/issues/3293
问题是attrs==19.2.0
删除了convert
属性(源(。
attr.ib(convert=int)
应弃用并替换为attr.ib(converter=int)
您要么需要更新使用attrs的任何内容,要么需要降级:pip install 'attrs<19.2.0'
只需使用命令
conda update conda
并重新启动系统。