+
    Bi+                     
   R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	H
t
Ht ^ RIt^ RIHtHt ^ RIHt ^ RIt]! ]! R 4      4      t]! ]! R 4      4      t]R	 4       t ! R
 R]4      t ! R R]4      t]R8X  d
   ]! 4        R# R# )z)
Test cases for pyclbr.py
Nick Mathewson
N)contextmanager)dedent)FunctionType
MethodTypeBuiltinFunctionType)TestCasemain)utilc                      R # N r       '/usr/lib/python3.14/test/test_pyclbr.py<lambda>r          Tr   c                     R # r   r   )cs   &r   r   r      r   r   c               #     "   \         P                  P                  R4      p V f   Rx  R# \        V RR4      pVf(   \        P
                  P                  RRRR7      V n         Rx  Wn        R#   Yn        i ; i5i)zl
A context manager that temporarily sets the `__spec__` attribute
of the `__main__` module if it's missing.
__main__N__spec__zbuilt-in)nameloaderorigin)sysmodulesgetgetattr	importlib	machinery
ModuleSpecr   )main_modoriginal_specs     r   temporary_main_specr"      sr      {{z*HHj$7M%//::D ; 
*)Ms   A"A<%A1 )A<1A99A<c                   T   a  ] tR t^2t o R tR tR tRR ltR tR t	R t
R	 tR
tV tR# )
PyclbrTestc                
   \        V4      \        V4      ,          \        V4      ,
          pV'       dP   \        RV: RV: RV: 2\        P                  R7       V P	                  RVP                  4       ,          4       R# R# )z/succeed iff {l1} - {ignore} == {l2} - {ignore} zl1=z
l2=z
ignore=filez
%r missingN)setprintr   stderrfailpop)selfl1l2ignoremissings   &&&& r   assertListEqPyclbrTest.assertListEq4   sQ    r7SW$F3r2v>SZZPIIlW[[]23 r   c                |    W#9   d   R# W!9  d   \        RV\        P                  R7       V P                  W!4       R# )z)succeed iff key in obj or key in ignore. Nz***r&   )r)   r   r*   assertIn)r-   objkeyr0   s   &&&&r   assertHaskeyPyclbrTest.assertHaskey;   s*    =&>%#**-cr   c                H    W9  d   W#9  d   V P                  W4       R# R# R# )z1succeed iff a == b or a in ignore or b in ignore N)assertEqual)r-   abr0   s   &&&&r   assertEqualsOrIgnored PyclbrTest.assertEqualsOrIgnoredB   s     ?qQ"  /?r   Nc           	     r   \        V4      \        R.4      ,          pVf   \        V\        4       / R.4      p\        P                  ! V4      pR pVP                  4        EF  w  rgWc9   d   K  V P                  W&4       \        W&4      p\        V\        P                  4      '       dX   V P                  V\        \        34       VP                  V8w  d   Ky  V P                  VP                  VP                  4       K  V P                  V\         4       VP                  V8w  d   K  VP"                   U	u. uF  qP$                  NK  	  p
p	VP&                   U	u. uF  p	\        V	RV	4      NK  	  pp	 V P)                  WV4       . pTP0                  P3                  4        F8  pTR8X  d   K  T! T\        Y4      T4      '       g   K'  TP5                  T4       K:  	  TP7                  R	4      ;p'       d|   . pTP8                  P3                  4        FZ  pTP;                  R
4      '       d0   TP=                  R
4      '       g   TP5                  R	T T 24       KI  TP5                  T4       K\  	  M#\?        TP8                  P3                  4       4      p T P)                  YT4       T P                  TP                  TP                  4       T PA                  TP$                  TPB                  T4       EK  	  R p\E        V4       FO  p\        W&4      p\        V\         \        34      '       g   K,  V! VV4      '       g   K=  V PG                  WFV4       KQ  	  R# u up	i u up	i    \+        RT,          \,        P.                  R7       h ; i   \+        RT,          \,        P.                  R7       h ; i)zsucceed iff pyclbr.readmodule_ex(modulename) corresponds
to the actual module object, module.  Any identifiers in
ignore are ignored.   If no module is provided, the appropriate
module is loaded with __import__.objectNz<silly>c                    V P                   p\        V\        4      '       d0   \        W2,          \        4      '       d   VP                  V Jd   R # M\        V\
        4      '       g   R # VP                  pVP                  R4      '       dB   VP                  R4      '       g+   V P                  P                  R4      ;p'       d   RV V 2pWB8H  # )F___)
__dict__
isinstancer   ClassMethodType__self__r   __name__
startswithendswithlstrip)oclassr6   r   	classdictobjnamestripped_typenames   &&&   r   ismethod(PyclbrTest.checkModule.<locals>.ismethodV   s    I#z**"9?ODDLL.  /\22llG!!$''0@0@0F0F(.(>(>s(CC$C !"3!4WI>G?"r   r   zclass=%sr&   __annotate__rD   rC   c                     \        V \        4      '       d   V P                  VP                  8H  # \        V \        4      '       d   V P
                  VP                  J # R # )F)rF   type
__module__rI   r   __globals__rE   )itemmodules   &&r   
defined_in*PyclbrTest.checkModule.<locals>.defined_in   sG    $%%&//99$--''6??::r   )$r(   
__import__globalspyclbrreadmodule_exitemsassertHasAttrr   rF   FunctionassertIsInstancer   r   rV   r;   rY   rU   	__bases__rI   superr2   r)   r   r*   rE   keysappendrL   methodsrJ   rK   listr>   r   dirr8   )r-   
moduleNamerY   r0   dictrQ   r   valuepy_itembase
real_basespyclbr_basesactualMethodsmrP   foundMethodsrZ   rX   s   &&&&              r   checkModulePyclbrTest.checkModuleG   s    VsH:.>  
GIrI;GF##J/	#"  ::<KD~v,f+G%11%%g>Q/RS%%3  !3!3U\\B%%gt4%%38?8I8IJ8Imm8I
J-2[[ ;-8T ")vt!<-8   ;%%jG
 !# ))..0AN* )<a@@%,,Q/	 1 )-C(88$8#%L"]]//1<<--ajj6F6F(//!4E3Fqc0JK(//2	 2 $((:(:(<#=L	%%l6J$$W%7%7F..w/?/?/57] (l	 KD6(D$$!566dF++%%d&9	  [ K ;
*w.SZZ@4*w.SZZ@s%   9MM$6M)AN)%N%N6c                    V P                  R 4       \        4       ;_uu_ 4        V P                  RRR7       RRR4       V P                  RRR7       R#   + '       g   i     L%; i)r^   doctestr0   Ndifflib)TestResults	_SpoofOutDocTestCase_DocTestSuite)Match)ru   r"   r-   s   &r   	test_easyPyclbrTest.test_easy   sX    " !""Y 0P Q # 	:6 #"s   AA%	c                0    V P                  R RR.R7       R# )ztest.pyclbr_inputomfry   N)ru   r   s   &r   
test_casesPyclbrTest.test_cases   s    ,dC[Ar   c           	       a aa \         oR RR/ R3w  rr4p\        R4      pSP                  WW6WE4      pSP                  VRV^^R7      pSP	                  VR^^4      p	SP	                  V	R^^4      p
SP                  VR	^^4      pSP                  VR
RV^^R7      pSP	                  VR^^
4      pSP                  VR^^4      pSP                  VR^^4      pSP	                  VR^^4      pRVR
V/pVVV 3R loS! RVRV4       R# )test ztest.pyNa          def f0():
            def f1(a,b,c):
                def f2(a=1, b=2, c=3): pass
                return f1(a,b,d)
            class c1: pass
        class C0:
            "Test class."
            def F1():
                "Method."
                return 'return'
            class C1():
                class C2:
                    "Class nested within nested class."
                    def F3(): return 1+1

        f0)
end_linenof1f2c1C0F1C1C2F3c                f  < SP                  VP                  4       VP                  4       4       VP                  4        F  pSP                  VP                  V 4       K!  	  VP                  4        F  pSP                  VP                  V4       K!  	  VP                  4        EF  pW,          W5,          rv\        V4      VP                  VP                  VP                  VP                  VP                  3p\        V4      VP                  VP                  VP                  VP                  VP                  3p	SP                  W4       \        V4      SP                  J d'   SP                  VP                  VP                  4       S
! WfP                  WwP                  4       EK	  	  R# )a9  Return equality of tree pairs.

Each parent,children pair define a tree.  The parents are
assumed equal.  Comparing the children dictionaries as such
does not work due to comparison by identity and double
linkage.  We separate comparing string and number attributes
from comparing the children of input children.
N)r;   rf   valuesassertIsparentrU   r   r'   rY   linenor   Classrh   children)parent1	children1parent2	children2obr7   o1o2t1t2comparembr-   s   &&&&      r   r   'PyclbrTest.test_nested.<locals>.compare   s%    Y^^-y~~/?@&&(bii1 )&&(bii1 ) ~~'"B"XrwwBIIr}}T"XrwwBIIr}}T  (8rxx'$$RZZ<KK[[9 (r   )r^   r   _create_treerb   _nest_function_nest_classr   )r-   rs   pr   tisourceactualr   r   r   r   r   r   r   r   r   expectedr   r   s   f                 @@r   test_nestedPyclbrTest.test_nested   s,   Ir47aA  " q!7 [[D!Q1[5r4A.r4A.^^Ba+XXatQbX9r4B/^^Bb"-^^Bb"-r4R0T"%	:0 	fdH-r   c                   V P                   pV! R R
R7       V! RRR7       \        P                  ! 4       ;_uu_ 4        \        P                  ! R\        4       V! RRR7       RRR4       \        4       ;_uu_ 4        V! RRR7       RRR4       V! RRR7       V! R4       V! R	4       R#   + '       g   i     LQ; i  + '       g   i     L?; i)randomry   pickler0   	sre_parseNpdbpydoczemail.parserztest.test_pyclbr)Random)partialPickleBuffer)dumpgroupspos)Union_ModuleTarget_ScriptTarget
_ZipTargetcurframe_locals_InteractState)inputoutput)ru   warningscatch_warningssimplefilterDeprecationWarningr"   )r-   cms   & r   test_othersPyclbrTest.test_others   s     	8K(
878$$&&!!(,>?{#<= ' !""* # 	7/0 	>
 '& #"s   &B->C -B=	 C	r   )Nr   )rI   rV   __qualname____firstlineno__r2   r8   r>   ru   r   r   r   r   __static_attributes____classdictcell____classdict__s   @r   r$   r$   2   s6     4 #
`:D7B;.z r   r$   c                   8   a  ] tR tRt o R tR tR tR tRtV t	R# )ReadmoduleTestsi
  c                L    \         P                  P                  4       V n        R # r   )r^   _modulescopyr   s   &r   setUpReadmoduleTests.setUp  s    ,,.r   c                0    V P                   \        n         R # r   )r   r^   r   s   &r   tearDownReadmoduleTests.tearDown  s    --r   c                P    V P                  \        \        P                  R 4       R# )zasyncio.fooN)assertRaisesImportErrorr^   r_   r   s   &r   test_dotted_name_not_a_package.ReadmoduleTests.test_dotted_name_not_a_package  s    
 	+v';';]Kr   c           	        R p\         P                  ! V4      ;_uu_ 4        V P                  \        4      ;_uu_ 4        \        P
                  ! V4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)doesnotexistN)test_importlib_utiluncacher   ModuleNotFoundErrorr^   r_   )r-   module_names   & r   test_module_has_no_spec'ReadmoduleTests.test_module_has_no_spec  sX    $ ((55""#677$$[1 8 6577 655s"   A;A(	A;(A83A;;B	)r   N)
rI   rV   r   r   r   r   r   r   r   r   r   s   @r   r   r   
  s     /(L2 2r   r   r   )__doc__importlib.machineryr   r   
contextlibr   textwrapr   typesr   r   r   r^   unittestr   r   unittest_maintest.test_importlibr	   r   r   rU   staticmethodStaticMethodTypeclassmethodrG   r"   r$   r   rI   r   r   r   <module>r      s   
  
 %  ? ?  4 ;  \23 {>23 * **U Up2h 20 zO r   