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

How to ignore some unittest test in Pycharm 2017.1?

Pycharm 测试 运行 window 中有一个按钮 "Show Ignored"。我想知道,如何将一些测试标记为忽略?

只需 Python unittest,您就可以用 @skip 装饰要跳过的测试。来自 unittest — Unit testing framework — Python 2 or 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 向您展示了跳过的测试。