我正在尝试将 unittest 属性添加到 Python 中的对象
class Boy:
def run(self, args):
print("Hello")
class BoyTest(unittest.TestCase)
def test(self)
self.assertEqual('2' , '2')
def self_test():
suite = unittest.TestSuite()
loader = unittest.TestLoader()
suite.addTest(loader.loadTestsFromTestCase(Boy.BoyTest))
return suite
"AttributeError: class Boy has no attribute 'BoyTest'"
但是,每当我打电话时,我都会收到self_test()
。为什么?