1、讀取xml配置文件報錯E AttributeError: 'function' object has no attribute 'read'
解決:少加了return_xml
word = self.read_xml.return_xml("test_001_search_key", "words")
2、xml文件標籤對寫錯了
解決:標籤多了> <words>python</words>>
3、TypeError: cannot unpack non-iterable NoneType object
解決:函數返回的變量個數不一致, 再加一個變量接收返回值
5、unittest suite 報 missing 1 required positional argument: 'test'
原代碼
suite = unittest.TestSuite
suite.addTest(TestFile())
解決: suite=unittest.TestSuite() # 報錯就是因爲這個後面沒有加括號
6、3.7 HTMLTestRunner測試報告生成後空。
沒有用load去加載。 或者ddt不支持addTest執行
suite = unittest.TestSuite()
suite.addTest(TestFile())
suite = unittest.TestSuite()
# suite.addTest(TestFile())
load = unittest.TestLoader()
suite.addTest(load.loadTestsFromTestCase(TestFile))
7、json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes
{
"case1":{"keys":"python"},
"case2":{"keys":"java"},
"case3":{"keys":"world"},
}
解決:最後一行數據多了個','
8.TypeError: loadTestsFromTestCase() missing 1 required positional argument: 'testCaseClass'
if __name__ == '__main__':
suit = unittest.TestSuite()
load = unittest.TestLoader
suit.addTest(load.loadTestsFromTestCase(TestDataDriver))
解決:TestLoader少加了個()