【发布时间】:2018-06-08 18:07:09
【问题描述】:
我可能是盲人并且在 Python 单元测试框架 (Python 2.7.10) 中遗漏了一些东西。我试图将一个类标记为预期的失败,但前提是该类在 Windows 上运行。其他平台正常工作。所以基本概念是:
@unittest.expectedFailureIf(sys.platform.startswith("win"), "Windows Fails")
class MyTestCase(unittest.TestCase):
# some class here
【问题讨论】:
-
哪个版本的python?
-
Python 版本 2.7.10
-
Python 2.7 没有
@unittest.expectedFailureIf()。也许你可以使用@unittest.skipIf(sys.platform.startswith("win"), "Windows Fails") -
这个请求描述了一个概念。两个平台都需要运行。如果我将它们标记为预期失败,它们将在 Mac 平台上返回意外成功。这当然是错的。他们应该在 Macintosh 上报告成功或失败,而在 Windows 上(由于错误)他们会报告失败,但使用 expectedFailureIf() 的概念,他们将在 Windows 上静音并报告为 expectedFailures。他们将在修复之日报告意外修复。一种更好的方法,因为一个平台将继续报告有效结果。跳过是不可接受的。有办法吗?
标签: python python-2.7 unit-testing