Py学习  »  pycharm

当使用python的pytest框架进行测试时,pycharm为测试生成奇怪的代码模板

l7ll7 • 5 年前 • 748 次点击  

为什么pycharm在单击“创建新测试…”时生成以下代码模板,即使我已经 pytest 作为我的默认测试运行程序?

如果我的功能是 create_training_data ,然后pycharm将为此生成以下代码:

from unittest import TestCase

class TestCreate_training_data(TestCase):
    def test_create_training_data(self):
    self.fail()

然而 脓包 既不需要导入,也不需要子类化,

class TestCreate_training_data(object):
    def test_create_training_data(self):
    self.fail()

这就足够了,因为“入门”页面已经显示: https://docs.pytest.org/en/latest/getting-started.html

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/30780
 
748 次点击  
文章 [ 1 ]  |  最新文章 5 年前
Pavel Karateev
Reply   •   1 楼
Pavel Karateev    5 年前

Pycharm只知道如何创造 unittest 目前正在测试。请为相应的功能请求投票: PY-15021 .