Last active
December 22, 2017 09:09
-
-
Save 007bsd/3d7b265e781edcb0be0bc7697c5c1a9b to your computer and use it in GitHub Desktop.
Snippet to collect executions statostics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import collections | |
| from lxml import etree | |
| def collect_suite_stats(suite_output): | |
| """ | |
| Extract suite execution statistics from output file | |
| :param suite_output: file with suite output | |
| :return: suite statistics | |
| """ | |
| def _suite_stats_collect(suite_root): | |
| """ | |
| Dive into suite result tree to collect statistics | |
| :param suite_root: suite root element | |
| :return: | |
| """ | |
| suites = suite_root.findall('suite') | |
| if suites: | |
| for suite in suites: | |
| _suite_stats_collect(suite) | |
| tests = suite_root.findall('test') | |
| if tests: | |
| for test in tests: | |
| suite_statistics['Tests'] += 1 | |
| suite_statistics['Failed'] += test.find('status').attrib['status'] == 'FAIL' | |
| suite_statistics = collections.Counter() | |
| suite_root = etree.parse(suite_output).getroot() | |
| _suite_stats_collect(suite_root) | |
| return suite_statistics |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment