Fix problems with unicode in junit XML output when writing to HTML report

Review Request #4051 - Created July 6, 2016 and submitted

Information
Eric Ayers
pants
zundel/unicode-in-html-report
3627, 3628
cf4019b...
Reviewers
pants-reviews
gmalmquist, molsen, stuhood

When there is unicode in the XML output, using --test-junit-html-report would result in an exception similar to:

File "/Users/zundel/Src/Pants/src/python/pants/backend/jvm/tasks/junit_run.py", line 568, in _execute
    _do_report(exception=None)
  File "/Users/zundel/Src/Pants/src/python/pants/backend/jvm/tasks/junit_run.py", line 562, in _do_report
    html_file_path = JUnitHtmlReport().report(self.workdir, os.path.join(self.workdir, 'reports'))
  File "/Users/zundel/Src/Pants/src/python/pants/backend/jvm/tasks/reports/junit_html_report.py", line 104, in report
    fp.write(self.generate_html(testsuites))

Exception message: 'ascii' codec can't encode character u'\xe5' in position 3508: ordinal not in range(128)

This change converts the encoding to binary before writing it to the file.

Added a unit test that reproduces the problem.

CI green at https://travis-ci.org/pantsbuild/pants/builds/143000429

Eric Ayers
Chris Heisterkamp
Chris Heisterkamp
Nick Howard (Twitter)
Eric Ayers
Eric Ayers
Review request changed

Status: Closed (submitted)

Change Summary:

Thanks Chris & Nick. Commit 534eb57.

Loading...