'@return: document as unicode (UTF-8 declared) XML according to Ant JUnit spec'

def xml_element(self):

    testsuite = ET.Element('testsuite')
    testsuite.set('tests', str(self.num_tests))
    testsuite.set('failures', str(self.num_failures))
    testsuite.set('time', str(self.time))
    testsuite.set('errors', str(self.num_errors))
    testsuite.set('name', self.name)
    for tc in self.test_case_results:
        tc.xml(testsuite)
    system_out = ET.SubElement(testsuite, 'system-out')
    system_out.text = cdata(filter_nonprintable_text(self.system_out))
    system_err = ET.SubElement(testsuite, 'system-err')
    system_err.text = cdata(filter_nonprintable_text(self.system_err))
    return ET.tostring(testsuite, encoding='utf-8', method='xml')
