gpt4 book ai didi

python - pytest-testmon 在写入结果期间因 TypeError 失败

转载 作者:行者123 更新时间:2023-12-04 16:45:49 25 4
gpt4 key购买 nike

为什么pytest --testmon失败并出现以下异常?

=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.7.3, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
testmon=True, changed files: 0, skipping collection of 102 files, run variant: default
rootdir: ../my_project
plugins: testmon-0.9.19
collected 0 items / 91 deselected
Traceback (most recent call last):
File "../my_project/venv3_test/bin/pytest", line 8, in <module>
sys.exit(main())
File "../my_project/venv3_test/lib/python3.7/site-packages/_pytest/config/__init__.py", line 93, in main
.....................
File "../my_project/venv3_test/lib/python3.7/site-packages/testmon/pytest_testmon.py", line 242, in pytest_sessionfinish
self.testmon_data.write_data()
File "../my_project/venv3_test/lib/python3.7/site-packages/testmon/testmon_core.py", line 197, in write_data
self._write_attribute('mtimes', self.source_tree.mtimes)
File "../my_project/venv3_test/lib/python3.7/site-packages/testmon/testmon_core.py", line 160, in _write_attribute
json_data = json.dumps(data)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
TypeError: encode() missing 1 required positional argument: 'o'

通过 pip 安装以下库:
pytest==5.3.5
pytest-watch==4.2.0
pytest-testmon==0.9.19

我正在使用 python3.7,试图更改 pytest-testmon 版本 tp 1.0.2,但它也失败了

最佳答案

看来json-datetime==0.0.5依赖中断 testmon .导入就够了:

import jsondatetime  # comment this line and the exception will disappear:

def test_something():
assert 1 == 1

关于python - pytest-testmon 在写入结果期间因 TypeError 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61544284/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com