
    dafz                     f   d dl Z d dlZd dlZd dlZd dlmZ d dlZd dlZd dlmZ d dl	Z	d dl
mZ  ej                  d      Z ej                  d      Z ej                  d      Z ej                  d      Z G d	 d
      Z G d de      Z ej&                  ee      \  ZZ G d de      Z ej&                  ee      \  ZZ G d de      Z ej&                  ee      \  ZZ G d de      Z ej&                  ee      \  ZZ G d de      Z ej&                  ee      \  Z Z! G d de      Z" ej&                  e"e      \  Z#Z$ G d de      Z% ej&                  e%e      \  Z&Z'dSdZ( G d d      Z) G d d      Z G d de)      Z* ej&                  e*      \  Z+Z, G d  d      Z G d! d"e)      Z- ej&                  e-      \  Z.Z/ G d# d$      Z0 G d% d&e)      Z1 ej&                  e1      \  Z2Z3 G d' de0      Z G d( d)e)      Z4 ej&                  e4      \  Z5Z6 G d* de0      Z e(e      Z7 G d+ d,e)      Z8 ej&                  e8      \  Z9Z: G d- de      Z e(e      Z; G d. d/e)      Z< ej&                  e8      \  Z=Z> G d0 d1      Z? G d2 d3      Z@ ej&                  e@ee4      \  ZAZB G d5 d6      ZC ej&                  eCee4      \  ZDZE G d7 d8      ZF ej&                  eFe79      \  ZGZH G d: d;      ZI ej&                  eIe79      \  ZJZK G d< d=      ZL ej&                  eLe7ee>      \  ZMZN G d? d@      ZO ej&                  eOe;A      \  ZPZQ G dB dC      ZR e(eRd      ZS G dD deR      Z% e(e%eeE      ZT G dF dG      ZU G dH dIeU      ZV ej&                  eVeeSJ      \  ZWZX ej                  ej                  dK       G dL dMeU             Z[ ej&                  e[eeeTN      \  Z\Z] G dO dP      Z^ ej&                  e^eSQ      \  Z_Z`eadRk(  r ej                          yy)T    N)import_helper)mock)util	importlibzimportlib.abczimportlib.machineryzimportlib.utilc                   *    e Zd ZdZg Zg Zd Zd Zd Zy)InheritanceTestszSTest that the specified class is a subclass/superclass of the expected
    classes.c                    | j                   D cg c]  }t        | j                  |       c}| _        t	        | d      r?| j                  j
                  }| j                  D cg c]  }t        ||       c}| _        | j                  s| j                  sJ | j                         t        | j                  | j                        | _
        y c c}w c c}w )Nsubclass_names)superclass_namesgetattrabcsuperclasseshasattr	machineryr
   
subclasses	__class___NAME_InheritanceTests__test)self
class_namer   s      7/root/Python-3.12.4/Lib/test/test_importlib/test_abc.pysetUpzInheritanceTests.setUp   s    /3/D/DF!+ %TXXz: F4)* **I151D1DF#-  'y*= FDO$"3"3CT^^C3dhh

3FFs   C$Cc                     | j                   D ]B  }| j                  t        || j                        dj	                  || j                               D y )Nz{0} is not a subclass of {1})r   
assertTrue
issubclassr   format)r   subclasss     r   test_subclassesz InheritanceTests.test_subclasses+   sE     	NHOOJx=.55hLN	N    c                     | j                   D ]B  }| j                  t        | j                  |      dj	                  || j                               D y )Nz{0} is not a superclass of {1})r   r   r   r   r   )r   
superclasss     r   test_superclassesz"InheritanceTests.test_superclasses1   sG    ++ 	QJOOJt{{J?/66z4;;OQ	Qr   N)	__name__
__module____qualname____doc__r   r   r   r   r"    r   r   r   r      s$     JL4NQr   r   c                       e Zd Zg Zg dZy)MetaPathFinder)BuiltinImporterFrozenImporter
PathFinderWindowsRegistryFinderNr#   r$   r%   r   r
   r'   r   r   r)   r)   8   s    /Nr   r)   )r   c                       e Zd Zg ZdgZy)PathEntryFinder
FileFinderNr.   r'   r   r   r0   r0   C   s    "^Nr   r0   c                       e Zd ZdgZy)ResourceLoaderLoaderN)r#   r$   r%   r   r'   r   r   r3   r3   M   s
     zr   r3   c                       e Zd ZdgZg dZy)InspectLoaderr4   )r*   r+   ExtensionFileLoaderNr.   r'   r   r   r6   r6   V   s     zQNr   r6   c                       e Zd ZdgZdgZy)ExecutionLoaderr6   r7   Nr.   r'   r   r   r9   r9   `   s    '(+,Nr   r9   c                       e Zd ZddgZddgZy)
FileLoaderr3   r9   SourceFileLoaderSourcelessFileLoaderNr.   r'   r   r   r;   r;   j   s    (*;<(*@ANr   r;   c                       e Zd ZddgZdgZy)SourceLoaderr3   r9   r<   Nr.   r'   r   r   r?   r?   t   s    (*;<()Nr   r?   c           	         || j                   }t        j                         D ci c]  \  }}|t        ||       }}}t	        j
                  | |fi |D ci c]  }|j                  |r |       n| c}S c c}}w c c}w N)r#   r   itemsr   	test_utilsplit_frozen_KIND)
base_classnameinstkwargskindsplitabcbaseclss           r   make_abc_subclassesrN      s    |"""%))+/h '(D)) /D / !--j$I&IK IIsu#- K K/Ks   A9A?c                       e Zd Zed        Zy)ABCTestHarnessc                 h    | j                   | j                     } |       }|| j                  _        |S rA   )SPLITrE   r   ins)r   rM   rS   s      r   rS   zABCTestHarness.ins   s.     jj$e 
r   N)r#   r$   r%   propertyrS   r'   r   r   rP   rP      s     r   rP   c                       e Zd Zy)r)   Nr#   r$   r%   r'   r   r   r)   r)          r   c                   "    e Zd Z ee      Zd Zy)MetaPathFinderDefaultsTestsc                 8    | j                   j                          y rA   rS   invalidate_cachesr   s    r   test_invalidate_cachesz2MetaPathFinderDefaultsTests.test_invalidate_caches       ""$r   N)r#   r$   r%   rN   r)   rR   r^   r'   r   r   rY   rY      s    /E%r   rY   c                       e Zd Zy)r0   NrV   r'   r   r   r0   r0      rW   r   c                   "    e Zd Z ee      Zd Zy)PathEntryFinderDefaultsTestsc                 8    | j                   j                          y rA   r[   r]   s    r   r^   z3PathEntryFinderDefaultsTests.test_invalidate_caches   r_   r   N)r#   r$   r%   rN   r0   rR   r^   r'   r   r   rb   rb      s    0E%r   rb   c                       e Zd Zy)r4   NrV   r'   r   r   r4   r4      rW   r   r4   c                   .    e Zd Z ee      Zd Zd Zd Zy)LoaderDefaultsTestsc                 \    d}| j                  | j                  j                  |             y )Nza spec)assertIsNonerS   create_module)r   specs     r   test_create_modulez&LoaderDefaultsTests.test_create_module   s$    $((0067r   c                     | j                  t              5  | j                  j                  d       d d d        y # 1 sw Y   y xY w)N	something)assertRaisesImportErrorrS   load_moduler]   s    r   test_load_modulez$LoaderDefaultsTests.test_load_module   s7    {+ 	.HH  -	. 	. 	.	   ;Ac                     t        j                  d      }t        j                         5  t        j                  dt
               t        |      }| j                  |_        | j                  t        |             d d d        y # 1 sw Y   y xY w)Nblahignore)
types
ModuleTypewarningscatch_warningssimplefilterDeprecationWarningreprrS   
__loader__r   )r   modoriginal_reprs      r   test_module_reprz$LoaderDefaultsTests.test_module_repr   sh    v&$$& 	'!!(,>? IM!XXCNOODI&	' 	' 	's   ABBN)	r#   r$   r%   rN   r4   rR   rk   rq   r   r'   r   r   rf   rf      s    'E8.'r   rf   c                        e Zd Z fdZ xZS )r3   c                 "    t         |   |      S rA   )superget_datar   pathr   s     r   r   zResourceLoader.get_data   s    w%%r   )r#   r$   r%   r   __classcell__r   s   @r   r3   r3      s    & &r   c                   "    e Zd Z ee      Zd Zy)ResourceLoaderDefaultsTestsc                     | j                  t              5  | j                  j                  d       d d d        y # 1 sw Y   y xY w)Nz
/some/path)rn   IOErrorrS   r   r]   s    r   test_get_dataz)ResourceLoaderDefaultsTests.test_get_data   s7    w' 	,HHl+	, 	, 	,rr   N)r#   r$   r%   rN   r3   rR   r   r'   r   r   r   r      s    /E,r   r   c                   (     e Zd Z fdZ fdZ xZS )r6   c                 "    t         |   |      S rA   )r   
is_packager   fullnamer   s     r   r   zInspectLoader.is_package       w!(++r   c                 "    t         |   |      S rA   )r   
get_sourcer   s     r   r   zInspectLoader.get_source   r   r   )r#   r$   r%   r   r   r   r   s   @r   r6   r6      s    ,, ,r   c                       e Zd ZeZd Zd Zy)InspectLoaderDefaultsTestsc                     | j                  t              5  | j                  j                  d       d d d        y # 1 sw Y   y xY wNrt   )rn   ro   rS   r   r]   s    r   test_is_packagez*InspectLoaderDefaultsTests.test_is_package   7    {+ 	(HH'	( 	( 	(rr   c                     | j                  t              5  | j                  j                  d       d d d        y # 1 sw Y   y xY wr   )rn   ro   rS   r   r]   s    r   test_get_sourcez*InspectLoaderDefaultsTests.test_get_source  r   rr   N)r#   r$   r%   SPLIT_ILrR   r   r   r'   r   r   r   r      s    E((r   r   c                        e Zd Z fdZ xZS )r9   c                 "    t         |   |      S rA   )r   get_filenamer   s     r   r   zExecutionLoader.get_filename  s    w#H--r   )r#   r$   r%   r   r   r   s   @r   r9   r9     s    . .r   c                       e Zd ZeZd Zy)ExecutionLoaderDefaultsTestsc                     | j                  t              5  | j                  j                  d       d d d        y # 1 sw Y   y xY wr   )rn   ro   rS   r   r]   s    r   test_get_filenamez.ExecutionLoaderDefaultsTests.test_get_filename  s7    {+ 	*HH!!&)	* 	* 	*rr   N)r#   r$   r%   SPLIT_ELrR   r   r'   r   r   r   r     s    E*r   r   c                   <     e Zd Z fdZ fdZ fdZ fdZ xZS )ResourceReaderc                 "    t        |   |i |S rA   )r   open_resourcer   argsrI   r   s      r   r   zResourceReader.open_resource%      w$d5f55r   c                 "    t        |   |i |S rA   )r   resource_pathr   s      r   r   zResourceReader.resource_path(  r   r   c                 "    t        |   |i |S rA   )r   is_resourcer   s      r   r   zResourceReader.is_resource+  s    w"D3F33r   c                 "    t        |   |i |S rA   )r   contentsr   s      r   r   zResourceReader.contents.  s    w000r   )r#   r$   r%   r   r   r   r   r   r   s   @r   r   r   #  s    6641 1r   r   c                   .    e Zd Zed        Zd Zd Zd Zy)MetaPathFinderFindModuleTestsc                 T     G fdd| j                   j                        } |       S )Nc                       e Zd Zd fd	Zy)@MetaPathFinderFindModuleTests.finder.<locals>.MetaPathSpecFinderNc                     ||f| _         S rA   )
called_for)r   r   r   targetrj   s       r   	find_speczJMetaPathFinderFindModuleTests.finder.<locals>.MetaPathSpecFinder.find_spec9  s    "*D.r   rA   )r#   r$   r%   r   )rj   s   r   MetaPathSpecFinderr   7  s    r   r   )r   r)   )rM   rj   r   s    ` r   finderz$MetaPathFinderFindModuleTests.finder5  s$    	!7!7 	 "##r   c                     t               }| j                  j                  d|      }| j                  |      }|j	                  ddd       }| j                  ||       y r   )objectr   spec_from_loaderr   r   assertEqualr   loaderrj   r   founds        r   #test_find_spec_with_explicit_targetzAMetaPathFinderFindModuleTests.test_find_spec_with_explicit_target?  sQ    yy))&&9T"  6%r   c                     | j                  d       }g d}d}|j                  ||d       }| j                  |       | j                  ||j                  d          | j                  ||j                  d          y )N)abcrt   r      )r   r   rh   r   r   )r   r   r   rG   r   s        r   test_no_specz*MetaPathFinderFindModuleTests.test_no_specF  sr    T"  tT2% v0034v0034r   c                     t               }| j                  j                  d|      }| j                  |      }|j	                  dd       }| j                  ||       y r   )r   r   r   r   r   assertIsr   s        r   	test_specz'MetaPathFinderFindModuleTests.test_specO  sM    yy))&&9T"  .eT"r   N)r#   r$   r%   classmethodr   r   r   r   r'   r   r   r   r   3  s#    $ $&5#r   r   )r   r   c                       e Zd Zd Zd Zd Zy)LoaderLoadModuleTestsc                 N     G d d| j                   j                        } |       S )Nc                       e Zd ZdZd Zd Zy)0LoaderLoadModuleTests.loader.<locals>.SpecLoaderNc                     || _         y rA   )r   r   modules     r   exec_modulez<LoaderLoadModuleTests.loader.<locals>.SpecLoader.exec_moduleb  s	    #
r   c                      y)z.Force some non-default module state to be set.Tr'   r   r   s     r   r   z;LoaderLoadModuleTests.loader.<locals>.SpecLoader.is_packagee  s    r   )r#   r$   r%   r   r   r   r'   r   r   
SpecLoaderr   `  s    E$r   r   )r   r4   )r   r   s     r   r   zLoaderLoadModuleTests.loader_  s     	 	 |r   c                     t        j                         5  t        j                  dt               | j	                         }d}t        j                  |      5  |j                  |       |j                  }| j                  t        j                  |   |       d d d        | j                  |j                         | j                  ||j                  j                         | j                  ||j                         | j                  ||j                  j                          | j#                  |j$                         | j#                  |j$                  |j                  j&                         d d d        y # 1 sw Y   xY w# 1 sw Y   y xY wNru   rt   )rx   ry   rz   r{   r   rC   uncacherp   r   r   sysmodulesr   r}   __spec__r#   rG   assertIsNotNone__path__submodule_search_locations)r   r   rG   r   s       r   
test_freshz LoaderLoadModuleTests.test_freshk  s3   $$& 	L!!(,>?[[]FD""4( 9""4(ckk$/89 VV%6%67VV__%;%;<T6??3T6??#7#78  1   & J JL	L 	L9 9		L 	Ls&   AFAE8CF8F	=FFc                 h   t        j                         5  t        j                  dt               d}| j	                         }t        j                  |      }| j                  j                  ||      |_	        ||_
        t        j                  |      5  |t        j                  |<   |j                  |       |j                   }| j#                  |t        j                  |          | j#                  |t        j                  |          d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY wr   )rx   ry   rz   r{   r   rv   rw   r   r   r   r}   rC   r   r   r   rp   r   r   )r   rG   r   r   r   s        r   test_reloadz!LoaderLoadModuleTests.test_reload|  s    $$& 	9!!(,>?D[[]F%%d+F"ii88vFFO &F""4( 9$*D!""4(eS[[%67fckk$&789	9 	99 9	9 	9s%   A?D(A7DD(D%	!D((D1N)r#   r$   r%   r   r   r   r'   r   r   r   r   ]  s    
L"9r   r   c                   ,    e Zd ZddZd Zd Zd Zd Zy)InspectLoaderSourceToCodeTestsNc                     t        j                  d      }| j                         }||j                  |      }n|j                  ||      }t	        ||j
                         |S )z!Help with source_to_code() tests.rt   )rv   rw   InspectLoaderSubclasssource_to_codeexec__dict__)r   datar   r   r   codes         r   source_to_modulez/InspectLoaderSourceToCodeTests.source_to_module  sZ    !!&)++-<((.D((t4DT6??#r   c                     d}| j                  |      }| j                  t        |d             | j                  |j                  d       y )N	attr = 42attr*   r   r   r   r   r   r   sourcer   s      r   test_source_to_code_sourcez9InspectLoaderSourceToCodeTests.test_source_to_code_source  s>    &&v./0b)r   c                     d}| j                  |      }| j                  t        |d             | j                  |j                  d       y )Ns	   attr = 42r   r   r   r   s      r   test_source_to_code_bytesz8InspectLoaderSourceToCodeTests.test_source_to_code_bytes  s>    &&v./0b)r   c                     d}| j                         }|j                  d|      }| j                  |j                  |       y )Nzpath/to/somewhere r   r   r   co_filename)r   r   r   r   s       r   test_source_to_code_pathz7InspectLoaderSourceToCodeTests.test_source_to_code_path  s=    "++-$$R.))40r   c                 ~    | j                         }|j                  d      }| j                  |j                  d       y )Nr   <string>r   )r   r   r   s      r   test_source_to_code_no_pathz:InspectLoaderSourceToCodeTests.test_source_to_code_no_path  s8     ++-$$R()):6r   rA   )r#   r$   r%   r   r   r   r  r  r'   r   r   r   r     s    	**17r   r   )r   c                       e Zd Zd Zd Zd Zy)InspectLoaderGetCodeTestsc                 `   t        j                  d      }t        j                  j	                  | j
                  d      5 }d|_        | j                         }|j                  d      }d d d        t        |j                         | j                  |j                  d       y # 1 sw Y   <xY w)Nrt   r   r   r   )rv   rw   r   patchr   r   return_valueget_coder   r   r   r   )r   r   mockedr   r   s        r   test_get_codez'InspectLoaderGetCodeTests.test_get_code  s    !!&)ZZt99<H 	+F"-F//1F??6*D	+ 	T6??#b)	+ 	+s    )B$$B-c                     t         j                  j                  | j                  d      5 }d |_        | j                         }|j                  d      }d d d        | j                         y # 1 sw Y   xY w)Nr   rt   )r   r  r   r   r	  r
  rh   )r   r  r   r   s       r   test_get_code_source_is_Nonez6InspectLoaderGetCodeTests.test_get_code_source_is_None  sg    ZZt99<H 	+F"&F//1F??6*D	+ 	$		+ 	+s   )A..A7c                     | j                         }| j                  t              5  |j                  d       d d d        y # 1 sw Y   y xY wr   )r   rn   ro   r
  r   r   s     r   test_get_code_source_not_foundz8InspectLoaderGetCodeTests.test_get_code_source_not_found  s?    ++-{+ 	$OOF#	$ 	$ 	$   AA
N)r#   r$   r%   r  r  r  r'   r   r   r  r    s    * $r   r  c                   8    e Zd ZdZdZd Zd Zd Zd Zd Z	d Z
y	)
InspectLoaderLoadModuleTestsz!Test InspectLoader.load_module().rt   c                     t        j                  | j                         | j                  t         j                  | j                         y rA   )r   unloadmodule_name
addCleanupr]   s    r   r   z"InspectLoaderLoadModuleTests.setUp  s0    T--.,,d.>.>?r   c                     | j                   j                  | j                  |      }t        j                         5  t        j
                  dt               | j                  j                  j                  |      cd d d        S # 1 sw Y   y xY wNru   )
r   r   r  rx   ry   rz   r{   init
_bootstrap_load_unlocked)r   r   rj   s      r   loadz!InspectLoaderLoadModuleTests.load  sh    yy))$*:*:FC$$& 	=!!(,>?99''66t<	= 	= 	=s   ?BBc                 V    t         j                  j                  | j                  d      S )Nr
  )r   r  r   r   r]   s    r   mock_get_codez*InspectLoaderLoadModuleTests.mock_get_code  s    zz  !;!;ZHHr   c                     | j                         5 }t        |_        | j                  t              5  | j	                         }| j                  |       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY wrA   )r   ro   side_effectrn   r   r  r   mocked_get_coder   s      r   test_get_code_ImportErrorz6InspectLoaderLoadModuleTests.test_get_code_ImportError  so    ! 	"_*5O'"";/ "335		&!"	" 	"" "	" 	"s"   !A1"A%A1%A.	*A11A:c                     | j                         5 }d |_        | j                  t              5  | j	                         }| j                  |       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY wrA   )r   r	  rn   ro   r   r  r#  s      r   test_get_code_Nonez/InspectLoaderLoadModuleTests.test_get_code_None  so    ! 	"_+/O("";/ "335		&!"	" 	"" "	" 	"s"   A-"A!A-!A*	&A--A6c                    t        ddd      }| j                         5 }||_        | j                         }| j	                  |      }| j                  |t        j                  | j                            d d d        y # 1 sw Y   y xY w)Nr   r  r   )	compiler   r	  r   r  r   r   r   r  )r   r   r$  r   r   s        r   test_module_returnedz1InspectLoaderLoadModuleTests.test_module_returned  sz    {J7! 	D_+/O(//1FYYv&FVS[[1A1A%BC		D 	D 	Ds   AA==BN)r#   r$   r%   r&   r  r   r  r   r%  r'  r*  r'   r   r   r  r    s+    +K@=I""Dr   r  )r   r  r   c                   2    e Zd ZddddZd Zd Zd Zd Zy)	ExecutionLoaderGetCodeTestsFr   r   c                    d\  }}|r*t         j                  j                  | j                  d      }|r*t         j                  j                  | j                  d      }||fS )N)NNr   r   )r   r  r   ExecutionLoaderSubclass)r   r   r   source_mock_contextfilename_mock_contexts        r   mock_methodsz(ExecutionLoaderGetCodeTests.mock_methods  sb    5?22"&**"3"3D4P4P4@#B$(JJ$5$5d6R6R6D%F!"$999r   c                    d}| j                  dd      \  }}|5 }|5 }d|_        ||_        | j                         }|j                  d      }d d d        d d d        | j	                  j
                  |       t        j                  d      }t        ||j                         | j	                  |j                  d       y # 1 sw Y   uxY w# 1 sw Y   yxY w)Nzblah.pyTr-  r   rt   r   )r2  r	  r/  r
  r   r   rv   rw   r   r   r   )	r   r   r0  r1  source_mock	name_mockr   r   r   s	            r   r  z)ExecutionLoaderGetCodeTests.test_get_code%  s    595F5Fd 6G 6422  	+K1F 	+)'2K$%)I"113F??6*D		+ 	+
 	))40!!&)T6??#b)	+ 	+ 	+ 	+s"   C0CCC	CCc                     | j                  d      \  }}|5 }d |_        | j                         }|j                  d      }d d d        | j	                         y # 1 sw Y   xY w)NT)r   rt   )r2  r	  r/  r
  rh   )r   r0  _r  r   r   s         r   r  z8ExecutionLoaderGetCodeTests.test_get_code_source_is_None3  si    !%!2!2d!2!CQ  	+F"&F113F??6*D	+ 	$		+ 	+s   )AA$c                     | j                         }| j                  t              5  |j                  d       d d d        y # 1 sw Y   y xY wr   )r/  rn   ro   r
  r  s     r   r  z:ExecutionLoaderGetCodeTests.test_get_code_source_not_found<  s?    --/{+ 	$OOF#	$ 	$ 	$r  c                    | j                  dd      \  }}|5 }|5 }d|_        t        |_        | j	                         }|j                  d      }d d d        d d d        | j                  j                  d       t        j                  d      }t        ||j                         | j                  |j                  d       y # 1 sw Y   uxY w# 1 sw Y   yxY w)NTr-  r   rt   r  r   )r2  r	  ro   r"  r/  r
  r   r   rv   rw   r   r   r   )r   r0  r1  r4  r5  r   r   r   s           r   test_get_code_no_pathz1ExecutionLoaderGetCodeTests.test_get_code_no_pathB  s     6:5F5Fd 6G 6422  	+K1F 	+)'2K$$/I!113F??6*D		+ 	+
 	)):6!!&)T6??#b)	+ 	+ 	+ 	+s"   C4CCC		CCN)r#   r$   r%   r2  r  r  r  r:  r'   r   r   r,  r,    s     ).U :* $*r   r,  )r/  c                   "    e Zd ZdZd Zd Zd Zy)SourceOnlyLoadersN   _ = '::'.join([__name__, __file__, __cached__, __package__, repr(__loader__)])c                     || _         y rA   r   r   r   s     r   __init__zSourceOnlyLoader.__init___  s	    	r   c                 D    || j                   k7  rt        | j                  S rA   )r   r   r   r?  s     r   r   zSourceOnlyLoader.get_datab  s    499M{{r   c                     | j                   S rA   r>  r   s     r   r   zSourceOnlyLoader.get_filenameg  s    yyr   N)r#   r$   r%   r   r@  r   r   r'   r   r   r<  r<  Y  s    $F
r   r<  c                   :     e Zd ZdZd fd	Z fdZd Zd Z xZS )r?   r   c                    t         |   |       | j                  j                  | j                        | _        t        | j                        | _        || j                  j                  }t        |      }|j                  | j                  j                  d             |j                  | j                  j                  | j                               |j                  | j                  j                  | j                               t        | j                  | j                  dd      }|j                  t!        j"                  |             t%        |      | _        i | _        y )Nr   r   T)dont_inherit)r   r@  r   cache_from_sourcer   bytecode_pathlenr   source_sizeMAGIC_NUMBER	bytearrayextendr  _pack_uint32source_mtimer)  marshaldumpsbytesbytecodewritten)r   r   magicr   code_objectr   s        r   r@  zSourceLoader.__init__r  s    !YY88Ct{{+=II**EDII**1-.DII**4+<+<=>DII**4+;+;<=dkk499f-13GMM+./dr   c                     || j                   k(  rt        | 	  |      S || j                  k(  r| j                  S t
        rA   )r   r   r   rG  rR  OSErrorr   s     r   r   zSourceLoader.get_data  s<    4997#D))T'''== Mr   c                 ^    || j                   k7  rt        | j                  | j                  dS )N)mtimesize)r   r   rN  rI  r?  s     r   
path_statszSourceLoader.path_stats  s*    499M**D4D4DEEr   c                 P    t        |      | j                  |<   || j                  k(  S rA   )rQ  rS  rG  )r   r   r   s      r   set_datazSourceLoader.set_data  s%    "4[Tt))))r   rA   )	r#   r$   r%   rN  r@  r   r[  r]  r   r   s   @r   r?   r?   n  s    L F
*r   )r   r  c                   $    e Zd ZdddZd Zd Zy)SourceLoaderTestHarnessTr   c                   d| _         |rAt        j                  j                  | j                   d      | _        | j                   | _        ndd}t        j                  j                  | j                   dj                  ddg            | _        dj                  | j                   |g      | _        | j
                  j                  | j                        | _         | j                  | j                  fi || _	        y )Npkgz__init__.pyr~   .py)
packageosr   joinrG   r   rF  cachedloader_mockr   )r   r   rI   r  s       r   r   zSourceLoaderTestHarness.setUp  s    T\\=ADIDIKT\\388UDM3JKDI$,,!<=DIii11$))<&d&&tyy;F;r   c                    | j                  |j                  | j                         | j                  |j                  | j                         | j                  |j
                  | j                         | j                  |j                  | j                         | j                  |j                  | j                         |j                  j                  d      }| j                  |d   | j                         | j                  |d   | j                         | j                  |d   | j                         | j                  |d   | j                         | j                  |d   t        | j                               y )Nz::r   r            )r   r#   rG   __file__r   
__cached__rh  __package__re  r}   r   r7  splitr|   )r   r   valuess      r   verify_modulez%SourceLoaderTestHarness.verify_module  s   $))4$))4**DKK8++T\\:**DKK8%DII.DII.DKK0DLL1D$56r   c                 &   t        j                  | j                        }| j                  |_        | j
                  |_        | j                  |_        | j                  |_
        g |_        t        ||j                         | j                  |       y rA   )rv   rw   rG   r   rn  rh  ro  re  rp  r   r}   r   r   r   rs  )r   rU  r   s      r   verify_codez#SourceLoaderTestHarness.verify_code  sh    !!$)),)) KK!\\ KK[&//*6"r   N)r#   r$   r%   r   rs  ru  r'   r   r   r_  r_    s    "& 
<7#r   r_  c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
SourceOnlyLoaderTestsz8Test importlib.abc.SourceLoader for source-only loading.c                    | j                   j                  j                  d      }| j                  | j                   j	                  | j
                        |       d }|| j                   _        | j                  t              5 }| j                   j	                  | j
                         d d d        | j                  j                  j
                  | j
                         y # 1 sw Y   :xY w)Nutf-8c                     t         rA   )rW  r>  s    r   raise_OSErrorz<SourceOnlyLoaderTests.test_get_source.<locals>.raise_OSError  s    Mr   )
r   r   decoder   r   rG   r   rn   ro   	exception)r   expected_sourcer{  cms       r   r   z%SourceOnlyLoaderTests.test_get_source  s     ++,,33G<//		:OL	,{+ 	.rKK""499-	.**DII6	. 	.s   &C##C,c                    | j                  d       | j                  | j                  j                  | j                               | j                  d       | j                  | j                  j                  | j                               | j                  | j                  j                  | j                  dz                y )NFr`  Tz	.__init__)r   assertFalser   r   rG   r   r]   s    r   r   z%SourceOnlyLoaderTests.test_is_package  s    

e
$//		:;

d
#..tyy9://		K0GHIr   c                 p    | j                   j                  | j                        }| j                  |       y rA   r   r
  rG   ru  r   rU  s     r   r  z#SourceOnlyLoaderTests.test_get_code  (    kk**4995%r   c                     | j                   j                  | j                   j                  | j                        }| j	                  |       y rA   )r   r   r   r   ru  )r   r   s     r   test_source_to_codez)SourceOnlyLoaderTests.test_source_to_code  s4    {{))$++*<*<diiHr   c                    t        j                         5  t        j                  dt               t	        j
                  | j                        5  t        j                         5  t        j                  dt               | j                  j                  | j                        }d d d        | j                         | j                  |j                  t        j                  j                  | j                        g       | j!                  | j                  t"        j$                         d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY wr  )rx   ry   rz   ImportWarningrC   r   rG   r{   r   rp   rs  r   r   rf  r   dirnameassertInr   r   r   s     r   rq   z&SourceOnlyLoaderTests.test_load_module  s     $$& 	6!!(M:""499- 6,,. @))(4FG![[44TYY?F@ ""6*  277??4993M2NOdii56	6 	6@ @6 6	6 	6s=   :EE$A D<$BE+E<EEE	EEc                 >   t        j                         5  t        j                  dt               | j	                  d       t        j                  | j                        5  t        j                         5  t        j                  dt               | j                  j                  | j                        }d d d        | j                         | j                  t        |d             d d d        d d d        y # 1 sw Y   FxY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nru   Fr`  r   )rx   ry   rz   r  r   rC   r   rG   r{   r   rp   rs  r  r   r   s     r   test_package_settingsz+SourceOnlyLoaderTests.test_package_settings  s     $$& 	>!!(M:JJ%J(""499- >,,. @))(4FG![[44TYY?F@ ""6*  !<=>	> 	>@ @> >	> 	>s=   AD!D6A C;64D*D;D DD	DDc                 h   d}|j                  d      | j                  _        | j                  j                  | j                        }| j                  ||       d}|j                  d      | j                  _        | j                  j                  | j                        }| j                  ||       y )Nu   _ = 'ü'ry  u   # coding: latin-1
_ = ülatin-1)encoder   r   r   rG   r   )r   r   returned_sources      r   test_get_source_encodingz.SourceOnlyLoaderTests.test_get_source_encoding  s     #]]73++00;&1,#]]95++00;&1r   N)r#   r$   r%   r&   r   r   r  r  rq   r  r  r'   r   r   rw  rw    s)    B
7J&

6>
2r   rw  )r   ri  zsys.dont_write_bytecode is truec                   R     e Zd ZdZdd fd
Zd Zd Zd Zd Zd	 Z	d
 Z
d Z xZS )SourceLoaderBytecodeTestszsTest importlib.abc.SourceLoader's use of bytecode.

    Source-only testing handled by SourceOnlyLoaderTests.

    Fbytecode_writtenc                   t         |   |       |rV| j                  | j                  | j                  j
                         t        | j                  j                        }|j                  | j                  j                  d             |j                  | j                  j                  | j                  j                               |j                  | j                  j                  | j                  j                               |j                  t        j                  |             | j!                  | j                  j
                  | j                     t#        |             y y )Nr   )r   ru  r  rh  r   rS  rK  r   rJ  rL  r  rM  rN  rI  rO  rP  r   rQ  )r   rU  r  r   r   s       r   ru  z%SourceLoaderBytecodeTests.verify_code  s    K(MM$++t{{':':;TYY334DKK		..q12KK		..t{{/G/GHIKK		..t{{/F/FGHKKk23T[[00=uT{K r   c                 p    | j                   j                  | j                        }| j                  |       y rA   r  r  s     r   test_code_with_everythingz3SourceLoaderBytecodeTests.test_code_with_everything!  r  r   c                 j   d| j                   _        | j                  t              5  | j                  j                  | j                        }| j                   j                  |       d d d        | j                   j                  | j                        }| j                  |d       y # 1 sw Y   BxY w)N<does not exist>Tr  )r   rG  rn   rW  r   rF  r   r   r
  rG   ru  )r   rG  rU  s      r   test_no_bytecodez*SourceLoaderBytecodeTests.test_no_bytecode&  s    $6!w' 	0 II77		BMKK  /	0 kk**4995t<		0 	0s   AB))B2c                 x   dD ]  }|| j                   j                  k7  sJ | j                   j                  }|| j                   _        | j                   j                  dd  | j                   _        | j                   j                  | j                        }| j                  |d       || j                   _         y )N)r   rk     Tr  )r   rN  rR  r
  rG   ru  )r   rN  originalrU  s       r   test_code_bad_timestampz1SourceLoaderBytecodeTests.test_code_bad_timestamp0  s    " 	0L4;;#;#;;;;{{//H'3DKK$#';;#7#7#;DKK ++..tyy9K[4@'/DKK$	0r   c                     | j                  d       | j                  j                  dd  | j                  _        | j                  j                  | j                        }| j                  |d       y )N   0000rT  r  Tr  )r   r   rR  r
  rG   ru  r  s     r   test_code_bad_magicz-SourceLoaderBytecodeTests.test_code_bad_magic<  sX    


!#{{33AB7kk**4995t<r   c                    	 dt         _        d| j                  _        | j                  j	                  | j
                        }| j                  | j                  | j                  j                         dt         _        y # dt         _        w xY w)NTr  F)	r   dont_write_bytecoder   rG  r
  rG   assertNotInrh  rS  r  s     r   test_dont_write_bytecodez2SourceLoaderBytecodeTests.test_dont_write_bytecodeD  sb    	,&*C#(:DKK%++..tyy9KT[[$++*=*=>&+C#eC#s   A1A? ?Bc                     | j                  d       | j                  j                  j                         d   j                  }	 | j                  j                  j                         d   `| j                  j                  | j                        }| j                  |       || j                  j                  j                         d   _        y # || j                  j                  j                         d   _        w xY w)Nr  r  r   )r   r   r   mror]  r
  rG   ru  )r   original_set_datarU  s      r   test_no_set_dataz*SourceLoaderBytecodeTests.test_no_set_dataO  s    


! KK11557:CC	H%%))+A.7++..tyy9K[)6GDKK!!%%'*36GDKK!!%%'*3s   AC .C=c                     d }| j                  d        |t              | j                  _        | j                  j	                  | j
                        }| j                  |       y )Nc                       fd}|S )Nc                      rA   r'   )r   rI   excs     r   closurezcSourceLoaderBytecodeTests.test_set_data_raises_exceptions.<locals>.raise_exception.<locals>.closure]  s    	r   r'   )r  r  s   ` r   raise_exceptionzRSourceLoaderBytecodeTests.test_set_data_raises_exceptions.<locals>.raise_exception\  s    Nr   r  r  )r   NotImplementedErrorr   r]  r
  rG   ru  )r   r  rU  s      r   test_set_data_raises_exceptionsz9SourceLoaderBytecodeTests.test_set_data_raises_exceptionsZ  sO    	
 	


!./BCkk**4995%r   )r#   r$   r%   r&   ru  r  r  r  r  r  r  r  r   r   s   @r   r  r    s8     <A 	L&
=
0=	,	H
&r   r  )r  r   ri  c                   "    e Zd ZdZd Zd Zd Zy)SourceLoaderGetSourceTestsz2Tests for importlib.abc.SourceLoader.get_source().c                     d}| j                  d      }d}|j                  d      |_         |j                  |      }| j	                  ||       y )Nr~   mod.fileu   x = "ü"ry  SourceOnlyLoaderMockr  r   r   r   r   rG   r   r   r  s        r   test_default_encodingz0SourceLoaderGetSourceTests.test_default_encodingq  sL    ((4mmG,)$//$/&1r   c                     d}| j                  d      }d}|j                  d      |j                  d      k7  sJ |j                  d      |_         |j                  |      }| j	                  ||       y )Nr~   r  u   # coding: Latin-1
x='ü'r  ry  r  r  s        r   test_decoded_sourcez.SourceLoaderGetSourceTests.test_decoded_sourcez  sl    ((4,}}Y'6==+AAAAmmI.)$//$/&1r   c                     d}| j                  d      }d}|j                  d      |_        t        j                  d d      j                  |      }| j                   |j                  |      |       y )Nr~   r  zx = 42
y = -13
ry  T)r  r  r   ioIncrementalNewlineDecoderr|  r   r   )r   rG   r   r   expects        r   test_universal_newlinesz2SourceLoaderGetSourceTests.test_universal_newlines  sd    ((4(mmG,--dD9@@H.7r   N)r#   r$   r%   r&   r  r  r  r'   r   r   r  r  m  s    <228r   r  )r  __main__)NF)cr  rO  rf  r   test.supportr   rv   unittestr   rx   test.test_importlibr   rC   import_importlibr  r   r   r   r)   	test_both%Frozen_MetaPathFinderInheritanceTests%Source_MetaPathFinderInheritanceTestsr0   &Frozen_PathEntryFinderInheritanceTests&Source_PathEntryFinderInheritanceTestsr3   %Frozen_ResourceLoaderInheritanceTests%Source_ResourceLoaderInheritanceTestsr6   $Frozen_InspectLoaderInheritanceTests$Source_InspectLoaderInheritanceTestsr9   &Frozen_ExecutionLoaderInheritanceTests&Source_ExecutionLoaderInheritanceTestsr;   !Frozen_FileLoaderInheritanceTests!Source_FileLoaderInheritanceTestsr?   #Frozen_SourceLoaderInheritanceTests#Source_SourceLoaderInheritanceTestsrN   rP   rY   Frozen_MPFDefaultTestsSource_MPFDefaultTestsrb   Frozen_PEFDefaultTestsSource_PEFDefaultTestsr4   rf   Frozen_LDefaultTestsSourceLDefaultTestsr   Frozen_RLDefaultTestsSource_RLDefaultTestsr   r   Frozen_ILDefaultTestsSource_ILDefaultTestsr   r   Frozen_ELDefaultTestsSource_ELDefaultsTestsr   r   Frozen_MPFFindModuleTestsSource_MPFFindModuleTestsr   Frozen_LoaderLoadModuleTestsSource_LoaderLoadModuleTestsr   Frozen_ILSourceToCodeTestsSource_ILSourceToCodeTestsr  Frozen_ILGetCodeTestsSource_ILGetCodeTestsr  Frozen_ILLoadModuleTestsSource_ILLoadModuleTestsr,  Frozen_ELGetCodeTestsSource_ELGetCodeTestsr<  	SPLIT_SOLSPLIT_SLr_  rw  Frozen_SourceOnlyLoaderTestsSource_SourceOnlyLoaderTestsskipIfr  r  Frozen_SLBytecodeTestsSourceSLBytecodeTestsr  %Frozen_SourceOnlyLoaderGetSourceTests%Source_SourceOnlyLoaderGetSourceTestsr#   mainr'   r   r   <module>r     sV   	  	 
 &     1!y!!+. i  1&I&&'<=	!y!!"23!Q !QH/% / YS1&&$& $ Yc2''"% " YS1&&R$ R YC0%%-& - Yc2''B! B Y-""*# * Y3/$$K 	 	
%. % Y45	 	
%> % Y56	 	
'. '0 Y,-&V &,. , Y45,F , }-
( 
( Y34.m . /*> * Y341 1 !# !#L Y6CdK
,9 ,9b Y.CdC
'7 '7X Y7/79
$ $: Y2/79
*D *D^ Y5/7""$6* 6*v Y419; $   0.A	#*# #*L |$TB## ##LG23 G2X Y.T%.0
 ((*KLV& 7 V& MV&v Y2D%-/
8 8F Y3.79&&
 zHMMO r   