判断是否是类,或者子类

 if isinstance(test, type) and issubclass(test,(case.TestCase, TestSuite)):
    raise TypeError("TestCases and TestSuites must be instantiated "
                            "before passing them to addTest()")
  • isinstance(test, type) 判断是否是类
  • issubclass(test,(case.TestCase, TestSuite))判断test是不是case.TestCase, TestSuite里的子类
posted @ 2022-07-21 23:58  我是小菜鸡丫丫  阅读(76)  评论(0编辑  收藏  举报