parser = CurrentBuildParser(getLogger()) tds = "abc" assert parser.__getBuildName(tds) == 'target'
报错:
AttributeError: 'CurrentBuildParser' object has no attribute '_Test_currentBuild__getBuildName'
如果把私有方法改成单下划线,即protected 方法,不会出现以上错误。
那么如何对类的私有方法进行测试呢?
parser = CurrentBuildParser(getLogger()) tds = "abc" assert parser._CurrentBuildParser__getBuildName(tds) == 'target'