§
    „Øjk-  ã                  óê   — d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
mZ dgZddej        ej        z  fd„Zdd„Z ej        d¦  «        Zddd„Zddd„Zd„ Zedk    r e¦   «          dS dS )zÔ
The testRunner module contains the all important "mainTest" function that runs tests
in a given module.  Except for the one instance of "defaultImports", everything here
can run on any system, not just music21.
é    )ÚannotationsN)ÚparenthesesMatchÚParenthesesMatchÚmusic21Fc           	     óª  — t          j        ¦   «         }|s2t          t          d         ¦  «        j                             ¦   «         }n|€i }|D ]„}t          j        |¦  «        sŒt          |dd¦  «        }|€Œ+|D ]V}||         }	| 	                    |	|||d¦  «        }
|
j
        sŒ+t          j        |
|¬¦  «        }|                      |¦  «         ŒWŒ…dS )a~  
    takes a suite, such as a doctest.DocTestSuite and the list of variables
    in a module and adds from those classes that have a _DOC_ATTR dictionary
    (which documents the properties in the class) any doctests to the suite.

    >>> import doctest
    >>> s1 = doctest.DocTestSuite(chord)
    >>> s1TestsBefore = len(s1._tests)
    >>> before = set(s1._tests)
    >>> allLocals = [getattr(chord, x) for x in dir(chord)]
    >>> test.testRunner.addDocAttrTestsToSuite(s1, allLocals)
    >>> s1TestsAfter = len(s1._tests)
    >>> s1TestsAfter - s1TestsBefore
    4
    >>> lastTest = s1._tests[-1]
    >>> lastTest
    client ()
    r   NÚ	_DOC_ATTR)Úoptionflags)ÚdoctestÚDocTestParserÚ
__import__ÚdefaultImportsÚ__dict__ÚcopyÚinspectÚisclassÚgetattrÚget_doctestÚexamplesÚDocTestCaseÚaddTest)ÚsuiteÚmoduleVariableListsÚouterFilenameÚglobsr	   ÚdtpÚlvkÚdocattrÚdockeyÚdocumentationÚdtÚdtcs               úŒ/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/music21/test/testRunner.pyÚaddDocAttrTestsToSuiter#   "   s  € õ4 Ô
Ñ
!Ô
!€CØð Ý�>¨!Ô,Ñ-Ô-Ô6×;Ò;Ñ=Ô=ˆˆà	ˆØˆà"ð ð ˆÝ” Ñ$Ô$ð 	ØÝ˜#˜{¨DÑ1Ô1ˆØˆ?ØØð 
	ð 
	ˆFØ# FœOˆMà—’ °°v¸}ÈaÑPÔPˆBØ”;ð ØÝÔ% bØ2=ð(ñ (ô (ˆCð �MŠM˜#ÑÔÐÐð
	ðð ó    ÚdoctestSuiteúdoctest._DocTestSuiteÚreturnÚNonec                ó^  — t          j        ¦   «         dk    }t          j        d         dk    }| D ]|}t	          |d¦  «        sŒ|j        }|j        D ]Z}t          |j        d¦  «        |_        |rt          |j        d¦  «        |_        |r |j         
                    dd¦  «        |_        Œ[Œ}d	S )
zç
    Fix doctests so that addresses are sanitized, WindowsPath is okay on windows
    and OrderedDicts pass on Python 3.12.

    In the past this fixed other differences among Python versions.
    In the future, it will again!
    ÚWindowsé   é   Ú_dt_testz0x...ú...Ú	PosixPathÚWindowsPathN)ÚplatformÚsystemÚsysÚversion_infoÚhasattrr-   r   ÚstripAddressesÚwantÚfix312OrderedDictÚreplace)r%   ÚwindowsÚisPython312r!   r    Úexamples         r"   ÚfixDoctestsr=   V   sÌ   € õ ”OÑ%Ô%¨Ò2€GÝÔ" 1Ô%¨Ò+€Kàð 
Pð 
PˆÝ�s˜JÑ'Ô'ð 	ØàŒ\ˆØ”{ð 	Pð 	PˆGÝ)¨'¬,¸Ñ@Ô@ˆGŒLØð FÝ0°´¸uÑEÔE�”Øð PØ&œ|×3Ò3°KÀÑOÔO�”øð	Pð
Pð 
Pr$   z0x[0-9A-Fa-f]+ÚADDRESSÚstrc                ó8   — t                                || ¦  «        S )a7  
    Function that changes all memory addresses (pointers) in the given
    textString with (replacement).  This is useful for testing
    that a function gives an expected result even if the result
    contains references to memory locations.  So for instance:

    >>> stripA = test.testRunner.stripAddresses
    >>> stripA('{0.0} <music21.clef.TrebleClef object at 0x02A87AD0>')
    '{0.0} <music21.clef.TrebleClef object at ADDRESS>'

    while this is left alone:

    >>> stripA('{0.0} <music21.humdrum.spineParser.MiscTandem *>I>')
    '{0.0} <music21.humdrum.spineParser.MiscTandem *>I>'

    For doctests, can strip to '...' to make it work fine with doctest.ELLIPSIS

    >>> stripA('{0.0} <music21.base.Music21Object object at 0x102a0ff10>', '0x...')
    '{0.0} <music21.base.Music21Object object at 0x...>'
    )r>   Úsub)Ú
textStringÚreplacements     r"   r6   r6   q   s   € õ* �;Š;�{ JÑ/Ô/Ð/r$   r.   c           	     ó|  — d| vr| S 	 t          | dd¬¦  «        }g }d}|D ]Y}|                     | ||j        t          d¦  «        z
  …         ¦  «         |                     d|z   dz   ¦  «         |j        dz   }ŒZ|                     | |d…         ¦  «         d	                     |¦  «        S # t          $ r |cY S w xY w)
aÚ  
    Function that fixes the OrderedDicts to work on Python 3.12 and above.
    (eventually when 3.12 is the norm, this should be replaced to neuter
    the doctests for 3.11 instead.  Or just wait until 3.12 is the minimum version?)

    >>> fix312 = test.testRunner.fix312OrderedDict
    >>> fix312('OrderedDict([(0, 1), (1, 2), (2, 3)])')
    'OrderedDict({...})'

    while this is left alone:

    >>> fix312('{0: 1, 1: 2, 2: 3}', 'nope!')
    '{0: 1, 1: 2, 2: 3}'
    zOrderedDict([(z)]))ÚopenÚcloser   zOrderedDict({z})é   NÚ )r   ÚappendÚstartÚlenÚendÚjoinÚ
ValueError)rB   rC   ÚmatchesÚoutÚlastÚms         r"   r8   r8   ‰   sï   € ð ˜zÐ)Ð)ØÐðÝ" :Ð4DÈEÐRÑRÔRˆØˆØˆàð 	ð 	ˆAØ�JŠJ�z $ q¤wµÐ5EÑ1FÔ1FÑ'FÐ"FÔGÑHÔHÐHØ�JŠJ�¨Ñ4°tÑ;Ñ<Ô<Ð<Ø”5˜1‘9ˆDˆDØ�
Š
�:˜d˜e˜eÔ$Ñ%Ô%Ð%Ø�wŠw�s‰|Œ|ÐøÝð ð ð ØÐÐÐðøøøs   ˆB#B, Â,B;Â:B;c                 óf  — d}t          |                     dd¦  «        ¦  «        }|r't          j        t          j        z  t          j        z  }nt          j        t          j        z  }d}d| v s?dt          j        v s1dt          j        v s#t          |                     dd¦  «        ¦  «        rd}nd}|rt          j	        ¦   «         }�n'd| v s1dt          j        v s#t          |                     dd¦  «        ¦  «        rnœt          D ](}t          |¦  «        j                             ¦   «         }Œ)d| v s1dt          j        v s#t          |                     dd¦  «        ¦  «        r7|                     t          j        ¦   «         d	         d
         j        ¦  «         	 t          j        d||¬¦  «        }n<# t&          $ r/}	t)          d|	› �¦  «         t          j	        ¦   «         }Y d}	~	nd}	~	ww xY wd	}
d| v s1dt          j        v s#t          |                     dd¦  «        ¦  «        rd}
d}dt          j        v sTdt          j        v sFt          |                     dd¦  «        ¦  «        s#t          |                     dd¦  «        ¦  «        rd}d}d}t+          t          j        ¦  «        dk    r:t          j        d	                              ¦   «         }|dvrt          j        d	         }t          |                     dd¦  «        ¦  «        r|                     dd¦  «        }dt          j        v s'd| v s#t          |                     dd¦  «        ¦  «        rg } | D �]�}t/          |t0          ¦  «        �sv|r4t          j                             |¦  «        D ]}t)          d|› �¦  «         Œ|��	 |¦   «         }t7          |¦  «        D ]Š}|                     ¦   «         |                     ¦   «         k    sZ|                     ¦   «         d|                     ¦   «         z   k    s-|                     ¦   «         d|                     ¦   «         z   k    r|} nŒ‹t9          ||¦  «        rBt)          d|› �¦  «         |                     ¦   «           t=          ||¦  «        ¦   «          d} nIt)          d|› d�¦  «         t          j                             |¦  «        }|                      |¦  «         �Œ‘|s€t          j        ¦   «         }t+          |¦  «        d	k    r	|d	         }n|d
         }|d
         }|d	         }tC          |j"         #                    ¦   «         ¦  «        }tI          |||||¦  «         |r@tK          |¦  «         t          j&        ¦   «         }|
|_'        | (                    |¦  «        }dS dS )at  
    Takes as its arguments modules (or a string 'noDocTest' or 'verbose')
    and runs all of these modules through a unittest suite

    Unless 'noDocTest' is passed as a module, a docTest
    is also performed on `__main__`, hence the name "mainTest".

    If 'moduleRelative' (a string) is passed as a module, then
    global variables are preserved.

    Run example (put at end of your modules):

    ::

        import unittest
        class Test(unittest.TestCase):
            def testHello(self):
                hello = 'Hello'
                self.assertEqual('Hello', hello)

        import music21
        if __name__ == '__main__':
            music21.mainTest(Test)

    This module tries to fix up some differences between python2 and python3 so
    that the same doctests can work.  These differences can now be removed, but
    I cannot remember what they are!
    TÚfailFastNÚ	noDocTestÚ	nodoctestFÚmoduleRelativeÚimportPlusRelativer+   r   Ú__main__)r   r	   zEProblem in docstrings [usually a missing r value before the quotes]: Úverboseé   ÚlistÚdisplay)r\   r]   rZ   rV   ÚrunTestÚonlyDocTestzUnit Test Method: ÚtestÚxtestzRunning Named Test Method: z"Could not find named test method: z, running all tests))ÚboolÚgetr
   ÚELLIPSISÚNORMALIZE_WHITESPACEÚREPORT_ONLY_FIRST_FAILUREr3   ÚargvÚunittestÚ	TestSuiter   r   r   r   Úupdater   ÚstackÚ	f_globalsÚDocTestSuiterN   ÚprintrK   ÚlowerÚ
isinstancer?   ÚdefaultTestLoaderÚgetTestCaseNamesÚdirr5   ÚsetUpr   ÚloadTestsFromTestCaseÚaddTestsr\   Úf_localsÚvaluesr#   r=   ÚTextTestRunnerÚ	verbosityÚrun)ÚtestClassesÚkeywordsÚrunAllTestsrT   r	   r   ÚskipDoctestÚs1ÚdiÚverz   ÚdisplayNamesÚrunThisTestÚargÚtÚtNameÚtObjÚnameÚs2ÚstacksÚouterFrameTupleÚ
outerFramer   ÚlocalVariablesÚrunnerÚunused_testResults                             r"   ÚmainTestr‘   «   sØ  € ð< €Kõ �H—L’L ¨TÑ2Ô2Ñ3Ô3€HØð 

åÔÝÔ*ñ+åÔ/ñ0ð 	ˆõ ÔÝÔ*ñ+ð 	ð
 €EØ�{Ð"Ð"Ø�cœhÐ&Ð&Ø�cœhÐ&Ð&Ý�H—L’L ¨eÑ4Ô4Ñ5Ô5ð 'àˆˆàˆð ð &åÔÑ!Ô!ˆ‰ð  Ð+Ð+Ø#¥s¤xÐ/Ð/Ý˜ŸšÐ%5°uÑ=Ô=Ñ>Ô>ð 0àå$ð 7ð 7�Ý" 2™œÔ/×4Ò4Ñ6Ô6��Ø$¨Ð3Ð3Ø+­s¬xÐ7Ð7Ý˜HŸLšLÐ)=¸uÑEÔEÑFÔFð 8ð —’�Wœ]™_œ_¨QÔ/°Ô2Ô<Ñ=Ô=Ð=ð	&ÝÔ%ØØØ'ðñ ô ˆBˆBøõ
 ð 	&ð 	&ð 	&ÝÐ^ÐZ\Ð^Ð^Ñ_Ô_Ð_ÝÔ#Ñ%Ô%ˆBˆBˆBˆBˆBˆBøøøøð	&øøøð €IØ�[Ð Ð Ø�CœHÐ$Ð$Ý�H—L’L ¨EÑ2Ô2Ñ3Ô3ð %àˆ	à€LØ•#”(ÐÐØ�CœHÐ$Ð$Ý�H—L’L ¨EÑ2Ô2Ñ3Ô3ð %å�H—L’L ¨Ñ/Ô/Ñ0Ô0ð %ð ˆØˆà€KÝ
�3Œ8�}„}˜ÒÐÝŒh�qŒk×ÒÑ!Ô!ˆØÐAÐAÐAåœ( 1œ+ˆKÝˆH�LŠL˜ EÑ*Ô*Ñ+Ô+ð 5Ø—l’l 9¨eÑ4Ô4ˆð 	�œÐ!Ð!Ø Ð+Ð+Ý�H—L’L °Ñ6Ô6Ñ7Ô7ð ,àˆØð ñ ˆÝ˜!�SÑ!Ô!ñ 	Øð 8Ý%Ô7×HÒHÈÑKÔKð 8ð 8�EÝÐ6¨uÐ6Ð6Ñ7Ô7Ð7Ð7ØÑ&Ø�q‘s”s�å ™IœIð ð �DØŸ
š
™œ¨×(9Ò(9Ñ(;Ô(;Ò;Ð;Ø"Ÿjšj™lœl¨v¸×8IÒ8IÑ8KÔ8KÑ/KÒLÐLØ"Ÿjšj™lœl¨w¸×9JÒ9JÑ9LÔ9LÑ/LÒMÐMØ&*˜Ø˜ð Nõ ˜4 Ñ-Ô-ð aÝÐE¸ÐEÐEÑFÔFÐFØ—J’J‘L”L�LØ.•G˜D +Ñ.Ô.Ñ0Ô0Ð0Ø"'�KØ�EåÐ_¸{Ð_Ð_Ð_Ñ`Ô`Ð`õ Ô+×AÒAÀ!ÑDÔDˆBØ�KŠK˜‰OŒOˆOùð ð 	VÝ”‘”ˆÝˆv‰;Œ;˜Š?ˆ?Ø$ QœiˆOˆOà$ QœiˆOØ$ QÔ'ˆ
Ø'¨Ô*ˆÝ˜jÔ1×8Ò8Ñ:Ô:Ñ;Ô;ˆÝ˜r >°=À%ÈÑUÔUÐUàð +Ý�B‰ŒˆåÔ(Ñ*Ô*ˆØ$ˆÔØ"ŸJšJ r™NœNÐÐÐð+ð +s   ÆF4 Æ4
G-Æ>%G(Ç(G-rY   )r%   r&   r'   r(   )r>   )r'   r?   )r.   )Ú__doc__Ú
__future__r   r
   r   r1   Úrer3   rh   Úmusic21.common.stringToolsr   r   r   rd   re   r#   r=   Úcompiler>   r6   r8   r‘   Ú__name__© r$   r"   ú<module>r™      s<  ððð ð
 #Ð "Ð "Ð "Ð "Ð "à €€€Ø €€€Ø €€€Ø 	€	€	€	Ø 
€
€
€
Ø €€€à IÐ IÐ IÐ IÐ IÐ IÐ IÐ Ià�€ð *.Ø!&à&Ô/Ø!(Ô!=ñ >ð1ð 1ð 1ð 1ðhPð Pð Pð Pð0 ˆ"Œ*Ð%Ñ
&Ô
&€ð0ð 0ð 0ð 0ð 0ð0ð ð ð ð ðD^+ð ^+ð ^+ðB ˆzÒÐØ€H�J„J€J€J€Jð Ðr$   