【发布时间】:2017-11-27 04:16:41
【问题描述】:
【问题讨论】:
-
有没有办法让pyCharm隐藏skitepd测试父组?例如,如果一个测试类包含跳过的测试,不要将整个类标记为已跳过,而是将其显示为通过?
标签: python pycharm python-unittest
【问题讨论】:
标签: python pycharm python-unittest
仅使用 Python unittest,您可以使用 @skip 装饰要跳过的测试。来自unittest — Unit testing framework — Python 2 或unittest — Unit testing framework — Python 3:
class MyTestCase(unittest.TestCase):
@unittest.skip("demonstrating skipping")
def test_nothing(self):
self.fail("shouldn't happen")
@unittest.skipIf(mylib.__version__ < (1, 3),
"not supported in this library version")
def test_format(self):
# Tests that work for only a certain version of the library.
pass
@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
def test_windows_support(self):
# windows specific testing code
pass
我假设 PyCharm 正在向您显示跳过的测试。
【讨论】:
@ignore 可能是一个更好的选择。 :)