How to use _report_testsuite_properties method in unittest-xml-reporting

Best Python code snippet using unittest-xml-reporting_python

result.py

Source:result.py Github

copy

Full Screen

...257 if testcase_name not in tests_by_testcase:258 tests_by_testcase[testcase_name] = []259 tests_by_testcase[testcase_name].append(test_info)260 return tests_by_testcase261 def _report_testsuite_properties(xml_testsuite, xml_document, properties):262 if properties:263 xml_properties = xml_document.createElement('properties')264 xml_testsuite.appendChild(xml_properties)265 for key, value in properties.items():266 prop = xml_document.createElement('property')267 prop.setAttribute('name', str(key))268 prop.setAttribute('value', str(value))269 xml_properties.appendChild(prop)270 _report_testsuite_properties = staticmethod(_report_testsuite_properties)271 def _report_testsuite(suite_name, tests, xml_document, parentElement,272 properties):273 """274 Appends the testsuite section to the XML document.275 """276 testsuite = xml_document.createElement('testsuite')277 parentElement.appendChild(testsuite)278 testsuite.setAttribute('name', suite_name)279 testsuite.setAttribute('tests', str(len(tests)))280 testsuite.setAttribute(281 'time', '%.3f' % sum(map(lambda e: e.elapsed_time, tests))282 )283 failures = filter(lambda e: e.outcome == e.FAILURE, tests)284 testsuite.setAttribute('failures', str(len(list(failures))))285 errors = filter(lambda e: e.outcome == e.ERROR, tests)286 testsuite.setAttribute('errors', str(len(list(errors))))287 skips = filter(lambda e: e.outcome == _TestInfo.SKIP, tests)288 testsuite.setAttribute('skipped', str(len(list(skips))))289 290 _XMLTestResult._report_testsuite_properties(291 testsuite, xml_document, properties)292 for test in tests:293 _XMLTestResult._report_testcase(test, testsuite, xml_document)294 systemout = xml_document.createElement('system-out')295 testsuite.appendChild(systemout)296 stdout = StringIO()297 for test in tests:298 # Merge the stdout from the tests in a class299 if test.stdout is not None:300 stdout.write(test.stdout)301 _XMLTestResult._createCDATAsections(302 xml_document, systemout, stdout.getvalue())303 systemerr = xml_document.createElement('system-err')304 testsuite.appendChild(systemerr)...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...208 if not testcase_name in tests_by_testcase:209 tests_by_testcase[testcase_name] = []210 tests_by_testcase[testcase_name].append(test_info)211 return tests_by_testcase212 def _report_testsuite_properties(xml_testsuite, xml_document, properties):213 xml_properties = xml_document.createElement('properties')214 xml_testsuite.appendChild(xml_properties)215 if properties:216 for key, value in properties.items():217 prop = xml_document.createElement('property')218 prop.setAttribute('name', str(key))219 prop.setAttribute('value', str(value))220 xml_properties.appendChild(prop)221 return xml_properties222 _report_testsuite_properties = staticmethod(_report_testsuite_properties)223 def _report_testsuite(suite_name, outsuffix, tests, xml_document, properties):224 """225 Appends the testsuite section to the XML document.226 """227 testsuite = xml_document.createElement('testsuite')228 xml_document.appendChild(testsuite)229 testsuite.setAttribute('name', "%s-%s" % (suite_name, outsuffix))230 testsuite.setAttribute('tests', str(len(tests)))231 testsuite.setAttribute(232 'time', '%.3f' % sum(map(lambda e: e.elapsed_time, tests))233 )234 failures = filter(lambda e: e.outcome == _TestInfo.FAILURE, tests)235 testsuite.setAttribute('failures', str(len(list(failures))))236 errors = filter(lambda e: e.outcome == _TestInfo.ERROR, tests)237 testsuite.setAttribute('errors', str(len(list(errors))))238 _XMLTestResult._report_testsuite_properties(testsuite, xml_document, properties)239 systemout = xml_document.createElement('system-out')240 testsuite.appendChild(systemout)241 stdout = StringIO()242 for test in tests:243 # Merge the stdout from the tests in a class244 stdout.write(test.stdout)245 _XMLTestResult._createCDATAsections(xml_document, systemout, stdout.getvalue())246 systemerr = xml_document.createElement('system-err')247 testsuite.appendChild(systemerr)248 stderr = StringIO()249 for test in tests:250 # Merge the stderr from the tests in a class251 stderr.write(test.stderr)252 _XMLTestResult._createCDATAsections(xml_document, systemerr, stderr.getvalue())...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run unittest-xml-reporting automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful