2017-10-16 83 views
-1

我使用HTMLRunner 1.1.1這是與Python兼容3.5HTMLTestRunner寫()參數必須海峽,而不是字節

我的代碼是:

dir=os.getcwd() 
photo_tests=unittest.TestLoader().loadTestsFromTestCase(Photo_Tests.Photo_Test) 
photo_tests_suit=unittest.TestSuite([photo_tests]) 

outfile=open(dir+"/Phototests.html","w") 
runner=HTMLTestRunner.HTMLTestRunner(stream=outfile,title="Tests with facebook photos") 

runner.run(photo_tests_suit) 

每一次,當我運行它,我得到一個錯誤:

File "/home/akop/py_workspace/MacPaw_FB/Photos_tests/TestsWithreport.py", line 13, in <module> 
    runner.run(photo_tests_suit) 
    File "/usr/lib/python3.5/HTMLTestRunner.py", line 601, in run 
    self.generateReport(test, result) 
    File "/usr/lib/python3.5/HTMLTestRunner.py", line 658, in generateReport 
    self.stream.write(output.encode('utf8')) 
TypeError: write() argument must be str, not bytes 
+0

可能的複製[builtins.TypeError:必須是str,而不是字節](https://stackoverflow.com/questions/5512811/builtins-typeerror-must-be-str-not-bytes) –

回答

0

這是我的錯字在outfile=open(dir+"/Phototests.html","w") - 應該有 「WB」,而不是 - 「W」

相關問題