有没有办法知道单元测试 class 是否完成了所有测试?

Is there a way to know if a unittest class is done with all the tests?

我有一个 class 实现了 unittest.TestCase;我想知道所有测试何时执行;并执行一些操作。

虽然我看不到如何获取此信息; class 似乎没有关于测试数量的线索,或者至少我无法找出隐藏此信息的位置。

我想做一个简单的检查,所以我可以在同一个文件中触发另一个 class,以执行一些分析和格式化数据。我在寻找实际上不可能的东西吗?

有一个特殊的 class 方法 - tearDownClass():

A class method called after tests in an individual class have run.

import unittest

class MyTestCase(unittest.TestCase):
    @classmethod
    def tearDownClass(cls):
        print("All the tests in this class are done")

    def test_something(self):
        self.assertTrue(True)

    def test_something_else(self):
        self.assertFalse(False)