为什么 PyCharm 在单击“创建新测试..:”时生成以下代码模板,即使我将 pytest
作为我的默认测试运行器?
如果我的函数是create_training_data
,那么 PyCharm 将为此生成以下代码:
from unittest import TestCase
class TestCreate_training_data(TestCase):
def test_create_training_data(self):
self.fail()
然而 pytest
既不需要导入,也不需要子类化
class TestCreate_training_data(object):
def test_create_training_data(self):
self.fail()
就足够了,因为入门页面已经显示:https://docs.pytest.org/en/latest/getting-started.html
最佳答案
PyCharm 目前只知道如何创建 unittest
测试。请为相应的功能请求投票:PY-15021 .
关于python - Pycharm 在使用 Python 的 pytest 框架进行测试时为测试生成奇怪的代码模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54524736/