a )g#"@sdZddlmZddlZddlZddlZddlZddlmZddl m Z ej Gdddej dZej Gd d d eZej Gd d d eZej Gd ddZej GdddZej GdddZddddZdddddZdS)z Dataclasses for creating JUnit XML files. See: https://github.com/junit-team/junit5/blob/main/platform-tests/src/test/resources/jenkins-junit.xsd ) annotationsN)minidom) ElementTreec@sreZdZUdZdZded<dZded<dZded<ddZe e j d d d d Z d d ddZ dd ddZdS) TestResultz)Base class for the result of a test case.N str | NoneoutputmessagetypecCs|jdur|j|_dSN)r tagselfrxz,TestCase.get_xml_element..cSsg|] }|qSrrA)rBr+rrrrCyrD system-out system-err) rrrr9 SubElementrextendr7r8r:r;rrrrr qszTestCase.get_xml_element)r!r"r#r$r%r1r2r3r4 dataclassesfieldlistr7r8r9r:r;r=r&r>r?r@rr rrrrr/Fs(          r/c@seZdZUdZded<dZded<dZded<dZded<dZd ed <e j e d Z d ed <e j e d Zded<dZded<dZded<ddZeddddZeddddZeddddZeddddZeddddZed dd!d"Zd dd#d$Zd%dd&d'ZdS)( TestSuitezA collection of test cases.rr0Nrhostnameidpackagezdatetime.datetime | None timestampr5r propertieszlist[TestCase]casesr:r;cCs,|jr(|jjtjjkr(tdtjjdS)Nztimestamp.tzinfo must be )rPtzinfodatetimetimezoneZutc ValueErrorr rrrrszTestSuite.__post_init__intrcCstdd|jDS)"The number of disabled test cases.css|] }|jVqdSr )r=rBZcaserrr rDz%TestSuite.disabled..sumrRr rrrdisabledszTestSuite.disabledcCstdd|jDS)/The number of test cases containing error info.css|] }|jVqdSr )r?rYrrrrZrDz#TestSuite.errors..r[r rrrr7szTestSuite.errorscCstdd|jDS)1The number of test cases containing failure info.css|] }|jVqdSr )r>rYrrrrZrDz%TestSuite.failures..r[r rrrr8szTestSuite.failurescCstdd|jDS)z1The number of test cases containing skipped info.css|] }|jVqdSr )r@rYrrrrZrDz$TestSuite.skipped..r[r rrrr9szTestSuite.skippedcCs t|jS)The number of test cases.)lenrRr rrrtestsszTestSuite.testsdecimal.DecimalcCsttdd|jDS)#The total time from all test cases.css|]}|jr|jVqdSr r4rYrrrrZrDz!TestSuite.time..)decimalDecimalr\rRr rrrr4szTestSuite.timecCsNt|j|j|j|j|j|j|j|j|j |j |j rF|j j ddj ddndd S)rN)rSZseconds)Ztimespec) r]r7r8rMrNr0rOr9rbr4rP)rr]r7r8rMrNr0rOr9rbr4rPreplaceZ isoformatr rrrrszTestSuite.get_attributesrcCs~td|}|jr8t|ddd|jD|dd|jD|jrd|jt|d_ |j rz|j t|d_ |S)rZ testsuiterQc Ss$g|]\}}tdt||dqS)r&)r0value)rrdict)rBr0rirrrrCrDz-TestSuite.get_xml_element..cSsg|] }|qSrrA)rBZ test_caserrrrCrDrErF) rrrrQrGrHitemsrRr:rr;rrrrr s"zTestSuite.get_xml_element)r!r"r#r$r%rMrNrOrPrIrJrjrQrKrRr:r;rr&r]r7r8r9rbr4rr rrrrrLs2       rLc@seZdZUdZdZded<ejedZ ded<e dd d d Z e dd d d Z e dd ddZ e dd ddZe dd ddZdd ddZdd ddZdd ddZdS) TestSuiteszA collection of test suites.Nrr0r5zlist[TestSuite]suitesrWrcCstdd|jDS)rXcss|] }|jVqdSr )r]rBZsuiterrrrZrDz&TestSuites.disabled..r\rmr rrrr]szTestSuites.disabledcCstdd|jDS)r^css|] }|jVqdSr )r7rnrrrrZrDz$TestSuites.errors..ror rrrr7szTestSuites.errorscCstdd|jDS)r_css|] }|jVqdSr )r8rnrrrrZrDz&TestSuites.failures..ror rrrr8szTestSuites.failurescCstdd|jDS)r`css|] }|jVqdSr )rbrnrrrrZrDz#TestSuites.tests..ror rrrrbszTestSuites.testsrccCsttdd|jDS)rdcss|] }|jVqdSr rernrrrrZrDz"TestSuites.time..)rfrgr\rmr rrrr4szTestSuites.timercCs t|j|j|j|j|j|jdS)r)r]r7r8r0rbr4)rr]r7r8r0rbr4r rrrrszTestSuites.get_attributesrcCs*td|}|dd|jD|S)rZ testsuitescSsg|] }|qSrrArnrrrrCrDz.TestSuites.get_xml_element..)rrrrHrmrrrrr szTestSuites.get_xml_elementrcCs t|S)z@Return a pretty formatted XML string representing this instance.) _pretty_xmlr r rrr to_pretty_xml szTestSuites.to_pretty_xml)r!r"r#r$r0r%rIrJrKrmr&r]r7r8rbr4rr rqrrrrrls   rlrrcKsdd|DS)zuReturn the given kwargs as a dictionary with values converted to strings. Items with a value of None will be omitted.cSs"i|]\}}|dur|t|qSr )r)rBkeyrirrr rDz_attributes..)rk)kwargsrrrrsrrr)rrcCsttj|ddS)zDReturn a pretty formatted XML string representing the given element.Zunicode)encoding)rZ parseStringrZtostringZ toprettyxml)rrrrrpsrp)r$Z __future__rr'rIrTrfZxml.domrZ xml.etreerrZ dataclassABCMetarr*r-r/rLrlrrprrrrs*     =R7