@staticmethod<EOL><INDENT>def write_unitth(suites, out_dir):<DEDENT>
if not os.path.isdir(out_dir):<EOL><INDENT>os.mkdir(out_dir)<EOL><DEDENT>for classname, cases in suites.items():<EOL><INDENT>doc_xml = minidom.Document()<EOL>suite_xml = doc_xml.createElement('<STR_LIT>')<EOL>suite_xml.setAttribute('<STR_LIT:name>', classname)<EOL>suite_xml.setAttribute('<STR_LIT>', str(len(cases)))<EOL>suite_xml.setAttribute('<STR_LIT>', str(sum('<STR_LIT:error>' in case for case in cases)))<EOL>suite_xml.setAttribute('<STR_LIT>', str(sum('<STR_LIT>' in case for case in cases)))<EOL>suite_xml.setAttribute('<STR_LIT>', str(sum('<STR_LIT>' in case for case in cases)))<EOL>suite_xml.setAttribute('<STR_LIT:time>', '<STR_LIT>'.format(sum(case['<STR_LIT:time>'] for case in cases)))<EOL>doc_xml.appendChild(suite_xml)<EOL>for case in cases:<EOL><INDENT>case_xml = doc_xml.createElement('<STR_LIT>')<EOL>case_xml.setAttribute('<STR_LIT>', classname)<EOL>case_xml.setAttribute('<STR_LIT:name>', case['<STR_LIT:name>'])<EOL>case_xml.setAttribute('<STR_LIT:time>', '<STR_LIT>'.format(case['<STR_LIT:time>']))<EOL>suite_xml.appendChild(case_xml)<EOL>if '<STR_LIT>' in case:<EOL><INDENT>skipped_xml = doc_xml.createElement('<STR_LIT>')<EOL>skipped_xml.setAttribute('<STR_LIT:type>', case['<STR_LIT>']['<STR_LIT:type>'])<EOL>skipped_xml.setAttribute('<STR_LIT:message>', case['<STR_LIT>']['<STR_LIT:message>'])<EOL>case_xml.appendChild(skipped_xml)<EOL>skipped_text_xml = doc_xml.createCDATASection(case['<STR_LIT>']['<STR_LIT:text>'])<EOL>skipped_xml.appendChild(skipped_text_xml)<EOL><DEDENT>if '<STR_LIT>' in case:<EOL><INDENT>failure_xml = doc_xml.createElement('<STR_LIT>')<EOL>failure_xml.setAttribute('<STR_LIT:type>', case['<STR_LIT>']['<STR_LIT:type>'])<EOL>failure_xml.setAttribute('<STR_LIT:message>', case['<STR_LIT>']['<STR_LIT:message>'])<EOL>case_xml.appendChild(failure_xml)<EOL>failure_text_xml = doc_xml.createCDATASection(case['<STR_LIT>']['<STR_LIT:text>'])<EOL>failure_xml.appendChild(failure_text_xml)<EOL><DEDENT>if '<STR_LIT:error>' in case:<EOL><INDENT>error_xml = doc_xml.createElement('<STR_LIT:error>')<EOL>error_xml.setAttribute('<STR_LIT:type>', case['<STR_LIT:error>']['<STR_LIT:type>'])<EOL>error_xml.setAttribute('<STR_LIT:message>', case['<STR_LIT:error>']['<STR_LIT:message>'])<EOL>case_xml.appendChild(error_xml)<EOL>error_text_xml = doc_xml.createCDATASection(case['<STR_LIT:error>']['<STR_LIT:text>'])<EOL>error_xml.appendChild(error_text_xml)<EOL><DEDENT><DEDENT>with open(os.path.join(out_dir, '<STR_LIT>'.format(classname)), '<STR_LIT:w>') as output:<EOL><INDENT>doc_xml.writexml(output, encoding='<STR_LIT:utf-8>', addindent='<STR_LIT>', newl="<STR_LIT>")<EOL><DEDENT>doc_xml.unlink()<EOL><DEDENT>
Write UnitTH-style test reports 

        Args:
            suites (:obj:`dict`): dictionary of test suites
            out_dir (:obj:`str`): path to save UnitTH-style test reports