【问题标题】:Pycharm generating weird code template for a test, when using Python's pytest framework for testing使用 Python 的 pytest 框架进行测试时,Pycharm 生成奇怪的代码模板进行测试
【发布时间】:2019-02-04 21:42:43
【问题描述】:

为什么 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

【问题讨论】:

    标签: python unit-testing pycharm pytest


    【解决方案1】:

    PyCharm 目前只知道如何创建unittest 测试。请为相应的功能请求投票:PY-15021

    【讨论】:

    • 在考虑实施之前,功能请求通常需要多少票?
    • 这取决于其他问题和问题的严重性。我相信在下一个发布计划中可以考虑这一点。
    猜你喜欢
    • 2019-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-18
    • 1970-01-01
    • 2019-01-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多