gpt4 book ai didi

pycharm - 在 PyCharm 中禁用自动单元测试

转载 作者:行者123 更新时间:2023-12-02 15:36:06 25 4
gpt4 key购买 nike

PyCharm 会自动检测文件何时以 test_ 开头,并尝试将它们作为单元测试运行。这是非常体贴的,但有些东西似乎被破坏了,在我运行的任何测试中,我得到

/Users/peter/projects/plato/venv/bin/python2.7 "/Applications/PyCharm CE.app/Contents/helpers/pycharm/utrunner.py" /Users/peter/projects/plato/utils/tools/test_sampling.py::::test_samplers_not_broken true
Testing started at 10:58 AM ...
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pycharm/utrunner.py", line 140, in <module>
all.addTest(testLoader.makeTest(getattr(module, a[2])))
AttributeError: 'TestLoader' object has no attribute 'makeTest'

Process finished with exit code 1

我想做的就是将它们作为普通的 python 文件运行,但 PyCharm 不允许我这样做。 Eclipse 提供正常运行或作为单元测试运行的选项。这很烦人!我怎样才能做到这一点?

最佳答案

here (小灰色箭头向下指向编辑器上方工具面板上的设置按钮附近)选择“编辑配置”

您可以在此处选择 pycharm 应运行哪些测试以及何时运行。可能设置了All in folder按钮,选择另一个选项,例如script

您还应该检查文件的底部,在 if __name__ == '__main__'

之后

也许您的代码可以在运行此文件时自动启动测试

关于pycharm - 在 PyCharm 中禁用自动单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28474516/

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