Skip to content

Instantly share code, notes, and snippets.

@e3krisztian
Created March 21, 2018 08:27
Show Gist options
  • Save e3krisztian/9e445253004b8100b3bb34e3f6b3a9f7 to your computer and use it in GitHub Desktop.
Save e3krisztian/9e445253004b8100b3bb34e3f6b3a9f7 to your computer and use it in GitHub Desktop.
experimental Junit wrapper for flake8
import sys
from xml.etree.ElementTree import ElementTree, XML, tostring as xml_tostring
JUNIT_SINGLE_SUCCESS = '''\
<?xml version="1.0" encoding="UTF-8"?>
<testsuite tests="1">
<testcase name="Clean code!"/>
</testsuite>
'''
JUNIT_SINGLE_FAILURE = '''\
<?xml version="1.0" encoding="UTF-8"?>
<testsuite tests="1">
<testcase name="Code smells">
<failure type="flake8"> details about failure </failure>
</testcase>
</testsuite>
'''
xml = ElementTree(XML(JUNIT_SINGLE_FAILURE))
e = xml.find('testcase/failure')
# print(e)
# e.set('type', 'flake8')
e.text = 'Eror: 1 < 2'
xml.write(sys.stdout, encoding='utf-8', xml_declaration=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment