python - 我应该如何指示尚未用 Python 编写测试?

标签 python unit-testing tdd

我正在使用 Python 和 unittest 模块进行 TDD。在 NUnit 中,您可以Assert.Inconclusive("This test hasn't been written")

到目前为止,我还没有在 Python 中找到任何类似的东西来表明“这些测试只是占位符,我需要回来并实际将代码放入其中。”

这有 Pythonic 模式吗?

最佳答案

随着new and updated unittest module你可以跳过测试:

@skip("skip this test")
def testSomething(self):
    pass # TODO

def testBar(self):
    self.skipTest('We need a test here, really')

def testFoo(self):
    raise SkipTest('TODO: Write a test here too')

当测试运行器运行这些时,它们被单独计算(“skipped: (n)”)。

关于python - 我应该如何指示尚未用 Python 编写测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12110610/

相关文章:

python - 如何使用python3分割字符串

python - 请求响应的 Xpath 返回空列表

python - HoverTool 的背景

python - 处理可变列数数据框 - Python

maven - 将 Java 8 项目迁移到 Jigsaw 时我应该在哪里放置单元测试

javascript - 如何使用 JEST 模拟方法内的方法?

python - 单元 : stop after first failing test?

c# - RhinoMock - AssertWasCalled 在具有不同参数的相同方法上不起作用

unit-testing - Rhino Mocks - 如何断言一个模拟方法被调用了 n 次?

unit-testing - 功能复杂的TDD如何应用?