ó
    G±‰jš:  ã                   óÚ   • S r SSKrSSKrSSKrSSKJrJrJr  SSKr	SSK
Jr   " S S\	R                  R                  R                  5      r " S S5      r " S	 S
\5      r " S S\5      rg)a'  unittest-xml-reporting is a PyUnit-based TestRunner that can export test
results to XML files that can be consumed by a wide range of tools, such as
build systems, IDEs and Continuous Integration servers.

This module provides the XMLTestRunner class, which is heavily based on the
default TextTestRunner. This makes the XMLTestRunner very simple to use.

The script below, adapted from the unittest documentation, shows how to use
XMLTestRunner in a very simple way. In fact, the only difference between this
script and the original one is the last line:

import random
import unittest
import xmlrunner

class TestSequenceFunctions(unittest.TestCase):
    def setUp(self):
        self.seq = range(10)

    def test_shuffle(self):
        # make sure the shuffled sequence does not lose any elements
        random.shuffle(self.seq)
        self.seq.sort()
        self.assertEqual(self.seq, range(10))

    def test_choice(self):
        element = random.choice(self.seq)
        self.assertTrue(element in self.seq)

    def test_sample(self):
        self.assertRaises(ValueError, random.sample, self.seq, 20)
        for element in random.sample(self.seq, 5):
            self.assertTrue(element in self.seq)

if __name__ == '__main__':
    unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))
é    N)Ú
TestResultÚTextTestResultÚTextTestRunner)ÚStringIOc                   ó   • \ rS rSrS rSrg)ÚXMLDocumenté1   c                 óR   • SU;   a  U R                  U5      $ U R                  U5      $ )Nz]]>)ÚcreateTextNodeÚcreateCDATASection)ÚselfÚdatas     Ú¤C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\Cython/Tests/xmlrunner.pyÚcreateCDATAOrTextÚXMLDocument.createCDATAOrText2   s+   € Ø�D‹=Ø×&Ñ& tÓ,Ð,Ø×&Ñ& tÓ,Ð,ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   Ú__static_attributes__r   r   r   r   r   1   s   † õ-r   r   c                   óP   • \ rS rSrSr\" S5      u  rrr\S4S jr	S r
S rS rS	rg)
Ú	_TestInfoé8   zTThis class is used to keep useful information about the execution of a
test method.
é   Nc                 óX  • Xl         X l        X0l        X@l        UR                  =(       a(    UR                  R                  5       R                  5       =(       d    SU l        UR                  =(       a(    UR                  R                  5       R                  5       =(       d    SU l        g)z#Create a new instance of _TestInfo.Ú N)Útest_resultÚtest_methodÚoutcomeÚerrÚstdoutÚgetvalueÚstripÚstderr)r   r   r    r!   r"   s        r   Ú__init__Ú_TestInfo.__init__@   sx   € à&ÔØ&ÔØŒØŒØ!×(Ñ(×R¨[×-?Ñ-?×-HÑ-HÓ-J×-PÑ-PÓ-R×XÐVXˆŒØ!×(Ñ(×R¨[×-?Ñ-?×-HÑ-HÓ-J×-PÑ-PÓ-R×XÐVXˆ�r   c                 ó\   • U R                   R                  U R                   R                  -
  $ )zEReturn the time that shows how long the test method took to
execute.
)r   Ú	stop_timeÚ
start_time©r   s    r   Úget_elapsed_timeÚ_TestInfo.get_elapsed_timeI   s'   € ð ×Ñ×)Ñ)¨D×,<Ñ,<×,GÑ,GÑGÐGr   c                 óL   • U R                   R                  U R                  5      $ )z0Return a text representation of the test method.)r   ÚgetDescriptionr    r,   s    r   Úget_descriptionÚ_TestInfo.get_descriptionO   s   € à×Ñ×.Ñ.¨t×/?Ñ/?Ó@Ð@r   c                 ó†   • U R                   (       d  gU R                  R                  U R                   U R                  5      $ )zFReturn a text representation of an exception thrown by a test
method.
r   )r"   r   Ú_exc_info_to_stringr    r,   s    r   Úget_error_infoÚ_TestInfo.get_error_infoS   s6   € ð �x�xØØ×Ñ×3Ñ3Ø�H‰H�d×&Ñ&ó(ð 	(r   )r"   r!   r&   r#   r    r   )r   r   r   r   Ú__doc__ÚrangeÚSUCCESSÚFAILUREÚERRORr'   r-   r1   r5   r   r   r   r   r   r   8   s5   † ññ
 !& a£Ñ€Wˆg�uà9@Àdô YòHòAõ(r   r   c                   óÂ   • \ rS rSrSr\R                  SSS4S jrS rS r	S r
S	 rS
 rS rS rS rS rS rS r\" \5      rS r\" \5      rS r\" \5      rS rSrg)Ú_XMLTestResulté]   z[A test result class that can express test results in a XML report.

Used by XMLTestRunner.
é   Tc                 óh   • [         R                  " XX#5        / U l        SU l        X@l        SU l        g)z(Create a new instance of _XMLTestResult.NF)r   r'   Ú	successesÚcallbackÚelapsed_timesÚoutput_patched)r   ÚstreamÚdescriptionsÚ	verbosityrC   s        r   r'   Ú_XMLTestResult.__init__b   s0   € ô 	×Ò ¨lÔFØˆŒØˆŒØ*ÔØ#ˆÕr   c                 óN   ^ ^^^• UR                  T5        U UUU4S jnUT l        g)zhAppend a _TestInfo to the given target list and sets a callback
method to be called by stopTest method.
c                  ó  >• T R                   (       d  S=T l        T l        T R                  (       a/  T R                  R                  STR                  5       T4-  5        gT R                  (       a  T R                  R                  T5        gg)zYThis callback prints the test method outcome to the stream,
as well as the elapsed time.
r   z
(%.3fs) %sN)	rC   r+   r*   ÚshowAllrE   Úwritelnr-   ÚdotsÚwrite)r   Ú	short_strÚ	test_infoÚverbose_strs   €€€€r   rB   Ú2_XMLTestResult._prepare_callback.<locals>.callbackp   sm   ø€ ð ×%×%Ø34Ð4�” $¤.à�|�|Ø—‘×#Ñ# LØ×/Ñ/Ó1°;Ð?ñ%@õ Aà——Ø—‘×!Ñ! )Õ,ð r   N)ÚappendrB   )r   rP   Útarget_listrQ   rO   rB   s   `` `` r   Ú_prepare_callbackÚ _XMLTestResult._prepare_callbackk   s&   û€ ð 	×Ñ˜9Ô%÷	-ð 	-ð !ˆ�r   c                 óú   • U R                   (       d2  [        R                  [        R                  sU l        U l        SU l         [        5       [        5       4=u  [        l        [        l        u  U l        U l        g)zgReplace the stdout and stderr streams with string-based streams
in order to capture the tests' output.
TN)rD   Úsysr#   r&   Ú
old_stdoutÚ
old_stderrr   r,   s    r   Ú_patch_standard_outputÚ%_XMLTestResult._patch_standard_output€   sT   € ð ×"×"Ü25·*±*¼c¿j¹jÐ.ˆTŒ_˜dœoØ"&ˆDÔä‹Zœ›Ð$ð	%Ñ ŒŒ”S”ZÑ#= D¤K°µr   c                 óh   • U R                   U R                  s[        l        [        l        SU l        g)z&Restore the stdout and stderr streams.FN)rY   rZ   rX   r#   r&   rD   r,   s    r   Ú_restore_standard_outputÚ'_XMLTestResult._restore_standard_outputŠ   s"   € à$(§O¡O°T·_±_Ð ŒŒ”S”ZØ#ˆÕr   c                 ó8  • U R                  5         [        R                  " 5       U l        [        R                  " X5        U R
                  (       aI  U R                  R                  SU R                  U5      -   5        U R                  R                  S5        gg)z'Called before execute each test method.z  z ... N)	r[   Útimer+   r   Ú	startTestrK   rE   rN   r0   ©r   Útests     r   rb   Ú_XMLTestResult.startTest�   si   € à×#Ñ#Ô%ÜŸ)š)›+ˆŒÜ×Ò˜TÔ(à�<�<Ø�K‰K×Ñ˜d T×%8Ñ%8¸Ó%>Ñ>Ô?Ø�K‰K×Ñ˜gÕ&ð r   c                 ó  • U R                  5         [        R                  " X5        [        R                  " 5       U l        U R
                  (       a3  [        U R
                  5      (       a  U R                  5         SU l        ggg)z&Called after execute each test method.N)r^   r   ÚstopTestra   r*   rB   Úcallablerc   s     r   rg   Ú_XMLTestResult.stopTest™   sU   € à×%Ñ%Ô'Ü×Ò Ô+ÜŸš›ˆŒà�=�=œX d§m¡m×4Ñ4Ø�M‰MŒOØ ˆD�Mð 5ˆ=r   c                 óR   • U R                  [        X5      U R                  SS5        g)z)Called when a test executes successfully.ÚOKÚ.N)rU   r   rA   rc   s     r   Ú
addSuccessÚ_XMLTestResult.addSuccess£   s"   € à×Ñœy¨Ó4Ø#Ÿ~™~¨t°Sõ	:r   c                 ór   • U R                  [        X[        R                  U5      U R                  SS5        g)z Called when a test method fails.ÚFAILÚFN)rU   r   r:   Úfailures©r   rd   r"   s      r   Ú
addFailureÚ_XMLTestResult.addFailure¨   s,   € à×Ñœy¨´Y×5FÑ5FÈÓLØ#Ÿ}™}¨f°cõ	;r   c                 ór   • U R                  [        X[        R                  U5      U R                  SS5        g)z*Called when a test method raises an error.r;   ÚEN)rU   r   r;   Úerrorsrs   s      r   ÚaddErrorÚ_XMLTestResult.addError­   s*   € à×Ñœy¨´Y·_±_ÀcÓJØ#Ÿ{™{¨G°Sõ	:r   c                 ó’  • U H×  n[        U[        5      (       a  Uu  p4 UR                  5       n UR	                  5       n UR                  5       nU R                  R                  U R                  5        U R                  R                  SXU4-  5        U R                  R                  U R                  5        U R                  R                  SU-  5        MÙ     g! [         a    Sn N½f = f! [         a0     UR                  5       n NÍ! [         a    [        U5      n  Nåf = ff = f! [         a    [        U5      n Nóf = f)z=Write some information about the FAIL or ERROR to the stream.r   z%s [%.3fs]: %sz%sN)Ú
isinstanceÚtupler-   ÚAttributeErrorr1   r0   Ústrr5   rE   rL   Ú
separator1Ú
separator2)r   Úflavourrx   rP   Úexc_infoÚtÚdescrÚerr_infos           r   ÚprintErrorListÚ_XMLTestResult.printErrorList²   s%  € ãˆIÜ˜)¤U×+Ñ+Ø&/Ñ#�	ðØ×.Ñ.Ó0�ð+Ø!×1Ñ1Ó3�ð*Ø$×3Ñ3Ó5�ð �K‰K×Ñ §¡Ô0Ø�K‰K×ÑÐ 0°GÀÐ3FÑ FÔGØ�K‰K×Ñ §¡Ô0Ø�K‰K×Ñ  x¡Ö0ò/  øô "ó Ø’ðûô "ó +ð+Ø%×4Ñ4Ó6’EøÜ%ó +Ü 	›N“Eð+úð+ûô "ó *Ü˜y›>’ð*úsL    C±C1ÁD.ÃC.Ã-C.Ã1
D+Ã<DÄD'Ä#D+Ä&D'Ä'D+Ä.EÅEc                 óh  • 0 nU R                   U R                  U R                  4 Hˆ  nU H  n[        U[        5      (       d  [        SU< 35        M)  [        UR                  5      nUR                  S-   nUS:X  a  SnXTR                  -   nXa;  a  / X'   X   R                  U5        M�     MŠ     U$ )z¦This method organizes test results by TestCase module. This
information is used during the report generation, where a XML report
will be generated for each TestCase.
zUnexpected test result type: rl   z	__main__.r   )rA   rr   rx   r|   r   ÚprintÚtyper    r   r   rS   )r   Útests_by_testcaseÚtestsrP   ÚtestcaseÚmoduleÚtestcase_names          r   Ú_get_info_by_testcaseÚ$_XMLTestResult._get_info_by_testcaseÍ   s²   € ð
 Ðà—n‘n d§m¡m°T·[±[ÓAˆEÛ"�	Ü! )¬Y×7Ñ7ÝºyÐJÔKÙÜ 	× 5Ñ 5Ó6�ð "×,Ñ,¨sÑ2�Ø˜[Ó(Ø�FØ &×):Ñ):Ñ :�à Ó9Ø79Ð%Ñ4Ø!Ñ0×7Ñ7¸	ÖBó #ñ Bð" !Ð r   c                 ó¶  • UR                  S5      nUR                  U5        UR                  S[        U 5      5        UR                  S[        [	        U5      5      5        UR                  SS[        U Vs/ s H  oDR                  5       PM     sn5      -  5        [	        U Vs/ s H$  oDR                  [        R                  :X  d  M"  SPM&     sn5      nUR                  S[        U5      5        [	        U Vs/ s H$  oDR                  [        R                  :X  d  M"  SPM&     sn5      nUR                  S[        U5      5        U$ s  snf s  snf s  snf )	z2Appends the testsuite section to the XML document.Ú	testsuiteÚnamer�   ra   ú%.3fr?   rr   rx   )ÚcreateElementÚappendChildÚsetAttributer   ÚlenÚsumr-   r!   r   r:   r;   )Ú
suite_namer�   Úxml_documentr”   Úerr   rx   s          r   Ú_report_testsuiteÚ _XMLTestResult._report_testsuiteç   s  € à ×.Ñ.¨{Ó;ˆ	Ø× Ñ  Ô+à×Ñ˜v¤s¨:£Ô7Ø×Ñ˜w¬¬C°«J«Ô8à×Ñ˜v vÜ©uÓ5ªu¨!×#Ñ#Ö%©uÑ5Ó6ñ(7ô 	8ô ¡5ÓK¢5˜a¯I©I¼×9JÑ9JÑ,JŸ¡5ÑKÓLˆØ×Ñ˜z¬3¨x«=Ô9ä¡ÓG¢˜A¯)©)´y·±Ñ*F—a¡ÑGÓHˆØ×Ñ˜x¬¨V«Ô5àÐùò 6ùâKùò Hs   Á8EÂ'!EÃEÃ=!EÄ"Ec           
      ó8  • UR                  S5      nUR                  U5        UR                  S[        U 5      5        UR                  SUR                  R                  5       =(       d*    [        UR                  S[        UR                  5      5      5        UR                  SSUR                  5       -  5        UR                  [        R                  :w  aÁ  SUR                  S-
     nUR                  U5      nUR                  U5        UR                  S	[        UR                  S
   R                  5      5        UR                  S[        UR                  S   5      5        UR                  5       nUR                  U5      nUR                  U5        gg)z/Appends a testcase section to the XML document.rŽ   Ú	classnamer•   Ú_testMethodNamera   r–   )ÚfailureÚerrorr?   r‹   r   ÚmessageN)r—   r˜   r™   r   r    ÚshortDescriptionÚgetattrr-   r!   r   r9   r"   r   r5   r   )	rœ   r   Úxml_testsuiter�   rŽ   Ú	elem_namer¤   Ú
error_infoÚfailureTexts	            r   Ú_report_testcaseÚ_XMLTestResult._report_testcaseü   sX  € à×-Ñ-¨jÓ9ˆØ×!Ñ! (Ô+à×Ñ˜k¬3¨z«?Ô;Ø×Ñ˜f k×&=Ñ&=×&NÑ&NÓ&P÷ 'GÜ!(¨×)@Ñ)@ÐBSÜ),¨[×-DÑ-DÓ)Eó"Gô	Hð 	×Ñ˜f f¨{×/KÑ/KÓ/MÑ&MÔNà×Ñ¤9×#4Ñ#4Ó4Ø,¨[×-@Ñ-@ÀÑ-BÑCˆIØ"×0Ñ0°Ó;ˆGØ× Ñ  Ô)à× Ñ  ¬¨[¯_©_¸QÑ-?×-HÑ-HÓ)IÔJØ× Ñ  ¬C°·±ÀÑ0BÓ,CÔDà$×3Ñ3Ó5ˆJØ&×8Ñ8¸ÓDˆKØ×Ñ Õ,ð 5r   c                 ó  • UR                  S5      nUR                  U5        UR                  U5      nUR                  U5        UR                  S5      nUR                  U5        UR                  U5      nUR                  U5        g)zCAppends the system-out and system-err sections to the XML document.z
system-outz
system-errN)r—   r˜   r   )	Útest_runnerr©   r�   r#   r&   Ú	systemoutÚsystemout_textÚ	systemerrÚsystemerr_texts	            r   Ú_report_outputÚ_XMLTestResult._report_output  sz   € à ×.Ñ.¨|Ó<ˆ	Ø×!Ñ! )Ô,à%×7Ñ7¸Ó?ˆØ×Ñ˜nÔ-à ×.Ñ.¨|Ó<ˆ	Ø×!Ñ! )Ô,à%×7Ñ7¸Ó?ˆØ×Ñ˜nÕ-r   c           
      óz  • U R                  5       n[        UR                  [        5      (       aN  [        R
                  R                  UR                  5      (       d   [        R                  " UR                  5        UR                  5        GH”  u  p4[        5       n[        R                  X4U5      n/ / p‡U H•  n	[        R                  X9Xe5        U	R                  (       a,  UR                  SU	R                  5       U	R                  /5        U	R                   (       d  Mi  UR                  SU	R                  5       U	R                   /5        M—     [        R#                  XUSR%                  U5      SR%                  U5      5        UR'                  SS9n
[)        UR                  5      [        L aT  [+        UR                  < [        R,                  < SU< S3S5      n UR/                  U
5        UR1                  5         GMy  UR                  R/                  U
5        GM—     g! UR1                  5         f = f)	z:Generates the XML reports to a given XMLTestRunner object.z*****************Ú
Ú	)ÚindentzTEST-z.xmlÚwN)r‘   r|   Úoutputr   ÚosÚpathÚexistsÚmakedirsÚitemsr   r=   rŸ   r­   r#   Úextendr1   r&   rµ   ÚjoinÚtoprettyxmlr‹   ÚopenÚseprN   Úclose)r   r°   Úall_resultsÚsuiter�   Údocr”   r#   r&   rd   Úxml_contentÚreport_files               r   Úgenerate_reportsÚ_XMLTestResult.generate_reports%  s­  € à×0Ñ0Ó2ˆä�k×(Ñ(¬#×.Ñ.´r·w±w·~±~Àk×FXÑFX×7YÑ7YÜ�KŠK˜×*Ñ*Ô+à'×-Ñ-×/‰LˆEÜ“-ˆCô '×8Ñ8¸ÀsÓKˆIØ �FÛ�Ü×/Ñ/°¸YÔLØ—;—;Ø—M‘MÐ#6¸×8LÑ8LÓ8NÐPT×P[ÑP[Ð"\Ô]Ø—;—;‘;Ø—M‘MÐ#6¸×8LÑ8LÓ8NÐPT×P[ÑP[Ð"\Ö]ñ ô ×)Ñ)¨+À#Ø*.¯)©)°FÓ*;¸T¿Y¹YÀvÓ=NôPàŸ/™/°˜/Ð6ˆKä�K×&Ñ&Ó'¬3Ò.Ü"Ø ×'Ó'¬¯¬³ð$8Ø9<ó>�ð(Ø×%Ñ% kÔ2à×%Ñ%×'ð ×"Ñ"×(Ñ(¨×5ò3 0øð,  ×%Ñ%Õ'ús   Ç#H(È(H:)
rB   rC   rZ   rY   rD   r+   r&   r#   r*   rA   N)r   r   r   r   r7   rX   r&   r'   rU   r[   r^   rb   rg   rm   rt   ry   r‡   r‘   rŸ   Ústaticmethodr­   rµ   rÍ   r   r   r   r   r=   r=   ]   sŠ   † ñð "Ÿj™j°qÀAØ#ô$ò!ò*%ò$ò
'ò!ò:ò
;ò
:ò
1ò6!ò4ñ& %Ð%6Ó7Ðò-ñ. $Ð$4Ó5Ðò.ñ " .Ó1€Nõ 6r   r=   c                   ó.   • \ rS rSrSrSS jrS rS rSrg)	ÚXMLTestRunneriH  zJA test runner class that outputs the results in JUnit like XML files.
    Nc                 óz   • Uc  [         R                  nSU   n[        R                  " XX65        Xl        XPl        g)z'Create a new instance of XMLTestRunner.N)r?   é   )rX   r&   r   r'   r¼   rC   )r   r¼   rE   rF   ÚverboserC   rG   s          r   r'   ÚXMLTestRunner.__init__K  s4   € à‰>Ü—Z‘ZˆFØ˜7‘Oˆ	Ü×Ò ¨lÔFØŒØ*Õr   c                 ón   • [        U R                  U R                  U R                  U R                  5      $ )z_Create the TestResult object which will be used to store
information about the executed tests.
)r=   rE   rF   rG   rC   r,   s    r   Ú_make_resultÚXMLTestRunner._make_resultT  s.   € ô ˜dŸk™k¨4×+<Ñ+<Ø�N‰N˜D×.Ñ.ó0ð 	0r   c                 óì  • U R                  5       nU R                  R                  5         U R                  R                  S5        U R                  R                  UR                  5        [        R                  " 5       nU" U5        [        R                  " 5       nXC-
  nU R                  R                  5         U R                  R                  S5        UR                  U 5        UR                  5         U R                  R                  UR                  5        UR                  nU R                  R                  SXfS:g  =(       a    S=(       d    SU4-  5        U R                  R                  5         UR                  5       (       dÍ  U R                  R                  S5        [        UR                  5      [        UR                  5      p‡U(       a  U R                  R                  SU-  5        U(       a@  U(       a  U R                  R                  S	5        U R                  R                  S
U-  5        U R                  R                  S5        U$ U R                  R                  S5        U$ )z&Run the given test case or test suite.zRunning tests...zGenerating XML reports...zRan %d test%s in %.3fsr?   Úsr   zFAILED (zfailures=%dz, z	errors=%dÚ)rk   )r×   rE   rL   r�   ra   rÍ   ÚprintErrorsÚtestsRunÚwasSuccessfulrN   rš   rr   rx   )	r   rd   Úresultr+   r*   Ú
time_takenÚrunÚfailedÚerroreds	            r   rá   ÚXMLTestRunner.run[  sÏ  € ð ×"Ñ"Ó$ˆð 	�‰×ÑÔØ�‰×ÑÐ.Ô/Ø�‰×Ñ˜F×-Ñ-Ô.ô —Y’Y“[ˆ
ÙˆVŒÜ—I’I“Kˆ	ØÑ+ˆ
ð 	�‰×ÑÔØ�‰×ÑÐ7Ô8Ø×Ñ Ô%ð 	×ÑÔØ�‰×Ñ˜F×-Ñ-Ô.Ø�o‰oˆØ�‰×ÑÐ4Ø˜‘(×"˜s×( b¨*Ð5ñ6ô 	7à�‰×ÑÔð ×#Ñ#×%Ñ%Ø�K‰K×Ñ˜jÔ)Ü" 6§?¡?Ó3´S¸¿¹Ó5G�GÞØ—‘×!Ñ! -°&Ñ"8Ô9ÞÞØ—K‘K×%Ñ% dÔ+Ø—‘×!Ñ! +°Ñ"7Ô8Ø�K‰K×Ñ Ô$ð ˆð �K‰K×Ñ Ô%àˆr   )rC   r¼   )rl   NTFT)	r   r   r   r   r7   r'   r×   rá   r   r   r   r   rÑ   rÑ   H  s   † ñô+ò0õ+r   rÑ   )r7   r½   rX   ra   Úunittestr   r   r   Úxml.dom.minidomÚxmlÚior   ÚdomÚminidomÚDocumentr   r   r=   rÑ   r   r   r   Ú<module>rì      sb   ðñ$óN 
Û 
Û ß ?Ñ ?Û å ô-�#—'‘'—/‘/×*Ñ*ô -÷"(ñ "(ôJh6�^ô h6ôV>�Nõ >r   