-1

I'm using HTMLRunner 1.1.1 which is compatible with python 3.5

my code is :

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)

Each time,when I run it, I get an error:

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
Akop Akopov
  • 85
  • 4
  • 13
  • Possible duplicate of [builtins.TypeError: must be str, not bytes](https://stackoverflow.com/questions/5512811/builtins-typeerror-must-be-str-not-bytes) – Alexey R. Oct 16 '17 at 15:35

1 Answers1

0

It was my misprint in outfile=open(dir+"/Phototests.html","w") - there should be "wb", not -"w"

Akop Akopov
  • 85
  • 4
  • 13