繁体   English   中英

如何忽略Pycharm 2017.1中的某些单元测试?

[英]How to ignore some unittest test in Pycharm 2017.1?

在Pycharm测试运行窗口中有一个“显示忽略”按钮。 我想知道,如何将一些测试标记为忽略?

Pycharm截图

使用Python unittest ,您可以使用@skip要跳过的测试。 来自unittest - 单元测试框架 - Python 2unittest - 单元测试框架 - 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向你展示了跳过的测试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM