
    daf                        d dl mZmZ  ej                  d      Zd dlZd dlZd dlZd dlZ ej                  ej                  j                  du d       G d dej                               Z ej                  ee      \  ZZ ej                  ej                  j                  du d       G d d	             Z ej                  ee      \  ZZed
k(  r ej(                          yy)    )abcutilzimportlib.machineryNzno reasonable builtin modulec                   F    e Zd ZdZd Zd Zd Zd ZdxZZ	dZ
d Zd Zd	 Zy)
LoaderTestsz(Test load_module() for built-in modules.c                 B    dd| j                   j                  d| _        y )Nerrno )__name____package__
__loader__)	machineryBuiltinImporterverification)selfs    B/root/Python-3.12.4/Lib/test/test_importlib/builtin/test_loader.pysetUpzLoaderTests.setUp   s    )0+/>>+I+IK    c                    | j                  |t        j                         | j                  j	                         D ]!  \  }}| j                  t        ||      |       # | j                  |j                  t        j                         y)z;Verify that the module matches against what it should have.N)assertIsInstancetypes
ModuleTyper   itemsassertEqualgetattrassertInr
   sysmodules)r   moduleattrvalues       r   verifyzLoaderTests.verify   sg    fe&6&67,,224 	;KD%WVT2E:	;foos{{3r   c                     t        j                         5  t        j                  dt               | j                  j
                  j                  |      cd d d        S # 1 sw Y   y xY w)Nignore)warningscatch_warningssimplefilterDeprecationWarningr   r   load_module)r   names     r   r(   zLoaderTests.load_module   sP    $$& 	D!!(,>?>>11==dC	D 	D 	Ds   ?AA'c                     t        j                  t         j                  j                        5  | j	                  t         j                  j                        }| j                  |       d d d        y # 1 sw Y   y xY wN)r   uncacheBUILTINS	good_namer(   r!   )r   r   s     r   test_modulezLoaderTests.test_module   sS    \\$--112 	 %%dmm&=&=>FKK	  	  	 s   ;A22A;Nc                 P   t        j                  t         j                  j                        5  | j	                  t         j                  j                        }| j	                  t         j                  j                        }| j                  ||       d d d        y # 1 sw Y   y xY wr+   )r   r,   r-   r.   r(   assertIs)r   module1module2s      r   test_module_reusezLoaderTests.test_module_reuse+   so    \\$--112 	,&&t}}'>'>?G&&t}}'>'>?GMM'7+	, 	, 	,s   A%BB%c                     d}|t         j                  vsJ | j                  t              5 }| j	                  |       d d d        | j                  j                  j                  |       y # 1 sw Y   0xY w)N	dssdsdfff)r   builtin_module_namesassertRaisesImportErrorr(   r   	exceptionr)   )r   r)   cms      r   test_unloadablezLoaderTests.test_unloadable2   sh    333333{+ 	#rT"	#**D1	# 	#s   A--A6c                    d}|t         j                  vsJ t        j                  |      5  t	        j
                  |      }|t         j                  |<   d d d        | j                  t              5 }| j                  |       d d d        | j                  j                  j                  |       y # 1 sw Y   _xY w# 1 sw Y   <xY w)Nbuiltin_reload_test)r   r7   r   r,   r   r   r   r8   r9   r(   r   r:   r)   )r   module_namer   r;   s       r   test_already_importedz!LoaderTests.test_already_imported9   s     ,#":"::::\\+& 	.%%k2F'-CKK$	. {+ 	*r[)	***K8	. 	.	* 	*s   )B32B?3B<?C)r
   
__module____qualname____doc__r   r!   r(   r/   test_packagetest_lacking_parenttest_state_after_failurer4   r<   r@    r   r   r   r   
   sA     3K4D
  *.-L&  $,2
9r   r   )r   c                       e Zd ZdZd Zd Zd Z ej                  e	j                  j                  du d      d        Zy)InspectLoaderTestsz4Tests for InspectLoader methods for BuiltinImporter.c                     | j                   j                  j                  t        j                  j
                        }| j                  |       y r+   )r   r   get_coder   r-   r.   assertIsNoner   results     r   test_get_codez InspectLoaderTests.test_get_codeP   s4    //889P9PQ&!r   c                     | j                   j                  j                  t        j                  j
                        }| j                  |       y r+   )r   r   
get_sourcer   r-   r.   rL   rM   s     r   test_get_sourcez"InspectLoaderTests.test_get_sourceU   s4    //::4==;R;RS&!r   c                     | j                   j                  j                  t        j                  j
                        }| j                  |       y r+   )r   r   
is_packager   r-   r.   assertFalserM   s     r   test_is_packagez"InspectLoaderTests.test_is_packageZ   s4    //::4==;R;RS r   Nzall modules are built inc                     dD ]"  }t        | j                  j                  |      }$ | j                  t              5 } t
        j                  j                         d d d        y # 1 sw Y   y xY w)N)rK   rQ   rT   )r   r   r   r8   r9   r   r-   bad_name)r   	meth_namemethodr;   s       r   test_not_builtinz#InspectLoaderTests.test_not_builtin_   sc     B 	HIT^^;;YGF	H{+ 	+r4==))*	+ 	+ 	+s   !A''A0)r
   rA   rB   rC   rO   rR   rV   unittestskipIfr   r-   rX   r[   rG   r   r   rI   rI   K   sH     ?"
"
!
 X__T]]++t35OP+ Q+r   rI   __main__)test.test_importlibr   r   import_importlibr   r   r   r\   r$   r]   r-   r.   r   	test_bothFrozen_LoaderTestsSource_LoaderTestsrI   Frozen_InspectLoaderTestsSource_InspectLoaderTestsr
   mainrG   r   r   <module>rg      s    )!D!!"78	 
   ((D02PQ89#// 89 R89z T^^K95 ((D02PQ+ + R+< T^^&)< zHMMO r   