TypeError: attrib() got an unexpected keyword argument 'convert'

旧街凉风 提交于 2019-12-18 18:33:23

问题


This error occurred during automated testing of a python project on the CI server using pytest. I'm using pytest==4.0.2. This error only just started to occur, previous pipelines seem to work fine.

The full error:

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'

回答1:


pytest seems to have the package attrs as a dependency. attrs==19.2.0 was released around 2019-10-01 17:00 UTC. This seems to cause the problem above.

Switching back to attrs==19.1.0 fixes the problem. Just do the following:

pip install attrs==19.1.0

NOTE: I expect that the issue will be resolved either by attrs or pytest soon by releasing a new version. So this fix should only be temporary.

UPDATE: Moving the comment into the answer. This error does not occur on the newer versions of pytest i.e. pytest==5.2.0




回答2:


pytest fixed using deprecated keyword convert at 3.6.3 (https://docs.pytest.org/en/latest/changelog.html#pytest-3-6-3-2018-07-04). At 4.0.1, pytest merged code using convert (https://github.com/pytest-dev/pytest/pull/4427). This code was fixed on 5.2.0 (https://github.com/pytest-dev/pytest/pull/4795).




回答3:


pytest version 5.3.1 with attrs Version 19.3.0 works fine for me. [To check the pytest Version and attrs Version issue the following command:]

pip show pytest attrs

I solved the same problem by upgrading pytest module via pip command:

pip install -U pytest


来源:https://stackoverflow.com/questions/58189683/typeerror-attrib-got-an-unexpected-keyword-argument-convert

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!