
    daf}                        d dl mZ  ej                  d      Z ej                  d      Z ej                  d      Z ej                  d      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 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Z	 d dlZ G d d	      Z ej8                  ee      \  ZZ G d
 d      Z ej8                  eeee      \  Z Z! G d d      Z" ej8                  e"e      \  Z#Z$ G d d      Z% ej8                  e%eee      \  Z&Z' G d d      Z( ej8                  e(e      \  Z)Z* G d d      Z+ ej8                  e+e      \  Z,Z- G d dej\                        Z( ej^                  edu d       G d dej\                               Z0e1dk(  r ejd                          yy# e$ r dZY 8w xY w# e$ r dZY Aw xY w# e$ r dZY Jw xY w)    )utilzimportlib.abc	importlibzimportlib.machineryzimportlib.utilN)supportc                   "    e Zd ZdZd Zd Zd Zy)DecodeSourceBytesTestsu   string ='ü'c                     | j                   j                  d      }| j                  | j                  j	                  |      | j                          y )Nutf-8sourceencodeassertEqualr   decode_source)selfsource_bytess     8/root/Python-3.12.4/Lib/test/test_importlib/test_util.pytest_ut8_defaultz'DecodeSourceBytesTests.test_ut8_default'   s9    {{))'200>L    c                     d| j                   z   }|j                  d      }||j                  d      k7  sJ | j                  | j                  j	                  |      |       y )Nz# coding=latin-1
zlatin-1r	   r
   r   r   r   s      r   test_specified_encodingz.DecodeSourceBytesTests.test_specified_encoding+   sT    %3}}Y/v}}W555500>Gr   c                    dj                  | j                  | j                  g      }|j                  d      }| j                  | j                  j                  |      dj                  | j                  | j                  g             y )Nz
r	   
)joinr   r   r   r   r   r   s      r   test_universal_newlinesz.DecodeSourceBytesTests.test_universal_newlines1   sd    dkk4;;78}}W-00>DKK#=>	@r   N)__name__
__module____qualname__r   r   r   r    r   r   r   r   #   s    FMH@r   r   c                   H    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)ModuleFromSpecTestsc                      G d d      }| j                   j                  d |             }| j                  t              5  | j                  j                  |      }d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zd Zy)9ModuleFromSpecTests.test_no_create_module.<locals>.Loaderc                      y Nr   )r   modules     r   exec_modulezEModuleFromSpecTests.test_no_create_module.<locals>.Loader.exec_moduleA   s    r   N)r   r   r   r'   r   r   r   Loaderr#   @   s    r   r(   test)	machinery
ModuleSpecassertRaisesImportErrorr   module_from_specr   r(   specr&   s       r   test_no_create_modulez)ModuleFromSpecTests.test_no_create_module?   s]    	 	 ~~((:{+ 	6YY//5F	6 	6 	6s   A&&A/c                 F    G d d| j                   j                        }| j                  j                  d |             }| j                  j                  |      }| j                  |t        j                         | j                  |j                  |j                         y )Nc                       e Zd Zd Zy)CModuleFromSpecTests.test_create_module_returns_None.<locals>.Loaderc                      y r%   r   )r   r0   s     r   create_modulezQModuleFromSpecTests.test_create_module_returns_None.<locals>.Loader.create_moduleI   s    r   Nr   r   r   r6   r   r   r   r(   r4   H   s    r   r(   r)   )abcr(   r*   r+   r   r.   assertIsInstancetypes
ModuleTyper   r   namer/   s       r   test_create_module_returns_Nonez3ModuleFromSpecTests.test_create_module_returns_NoneG   sr    	TXX__ 	 ~~((:++D1fe&6&67$))4r   c                 V   d G d dt         j                         G fdd| j                  j                        }| j                  j                  d |             }| j                  j                  |      }| j                  |       | j                  |j                         y )Nzalready setc                       e Zd Zy)<ModuleFromSpecTests.test_create_module.<locals>.CustomModuleN)r   r   r   r   r   r   CustomModuler@   R   s    r   rA   c                       e Zd Z fdZy)6ModuleFromSpecTests.test_create_module.<locals>.Loaderc                 :     |j                         }|_        |S r%   )r<   r   )r   r0   r&   rA   r<   s      r   r6   zDModuleFromSpecTests.test_create_module.<locals>.Loader.create_moduleU   s    %dii0"&r   Nr7   )rA   r<   s   r   r(   rC   T   s    r   r(   r)   )r:   r;   r8   r(   r*   r+   r   r.   r9   r   r   )r   r(   r0   r&   rA   r<   s       @@r   test_create_modulez&ModuleFromSpecTests.test_create_moduleP   s    	5++ 		TXX__ 	
 ~~((:++D1fl3$/r   c                     | j                   j                  dt                     }| j                  j	                  |      }| j                  |j                  |j                         y Nr)   )r*   r+   objectr   r.   r   r   r<   r   r0   r&   s      r   test___name__z!ModuleFromSpecTests.test___name__^   sF    ~~((:++D1$))4r   c                     | j                   j                  dt                     }| j                  j	                  |      }| j                  |j                  |       y rG   )r*   r+   rH   r   r.   r   __spec__rI   s      r   test___spec__z!ModuleFromSpecTests.test___spec__c   sB    ~~((:++D1$/r   c                     t               }| j                  j                  d|      }| j                  j	                  |      }| j                  |j                  |       y rG   )rH   r*   r+   r   r.   assertIs
__loader__)r   loaderr0   r&   s       r   test___loader__z#ModuleFromSpecTests.test___loader__h   sG    ~~((8++D1f''0r   c                     | j                   j                  dt                     }| j                  j	                  |      }| j                  |j                  |j                         y )Nztest.pkg)r*   r+   rH   r   r.   r   __package__parentrI   s      r   test___package__z$ModuleFromSpecTests.test___package__n   sH    ~~((VX>++D1++T[[9r   c                     | j                   j                  dt               d      }| j                  j	                  |      }| j                  |j                  |j                         y )Nr)   T)
is_package)r*   r+   rH   r   r.   r   __path__submodule_search_locationsrI   s      r   test___path__z!ModuleFromSpecTests.test___path__s   sM    ~~((d(K++D1$*I*IJr   c                     | j                   j                  dt               d      }d|_        | j                  j                  |      }| j                  |j                  |j                         y )Nr)   	some/path)originT)	r*   r+   rH   has_locationr   r.   r   __file__r^   rI   s      r   test___file__z!ModuleFromSpecTests.test___file__x   sS    ~~((+(N ++D1$++6r   c                     | j                   j                  dt                     }d|_        d|_        | j
                  j                  |      }| j                  |j                  |j                         y )Nr)   r]   T)	r*   r+   rH   cachedr_   r   r.   r   
__cached__rI   s      r   test___cached__z#ModuleFromSpecTests.test___cached__~   sW    ~~((:! ++D1**DKK8r   N)r   r   r   r1   r=   rE   rJ   rM   rR   rV   r[   ra   re   r   r   r   r    r    =   s5    6505
0
1:
K
79r   r    )r8   r*   r   c                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	ResolveNameTestsz$Tests importlib.util.resolve_name().c                 \    | j                  d| j                  j                  dd              y )Nbaconr   r   resolve_namer   s    r   test_absolutezResolveNameTests.test_absolute   s#    $))"8"8$"GHr   c                 \    | j                  d| j                  j                  dd             y )Nri   spamrj   rl   s    r   test_absolute_within_packagez-ResolveNameTests.test_absolute_within_package   s#    $))"8"8&"IJr   c                     | j                  t              5  | j                  j                  dd       d d d        y # 1 sw Y   y xY w)N.bacon r,   r-   r   rk   rl   s    r   test_no_packagez ResolveNameTests.test_no_package   s9    {+ 	1II""8R0	1 	1 	1	   <Ac                 \    | j                  d| j                  j                  dd             y )Nzspam.eggs.baconrr   	spam.eggsrj   rl   s    r   test_in_packagez ResolveNameTests.test_in_package   s(    *//+F	Hr   c                 \    | j                  d| j                  j                  dd             y )Nz
spam.bacon..baconrx   rj   rl   s    r   test_other_packagez#ResolveNameTests.test_other_package   s'    //	;G	Ir   c                     | j                  t              5  | j                  j                  dd       d d d        y # 1 sw Y   y xY w)Nr{   ro   rt   rl   s    r   test_escapezResolveNameTests.test_escape   s9    {+ 	6II""9f5	6 	6 	6rv   N)
r   r   r   __doc__rm   rp   ru   ry   r|   r~   r   r   r   rg   rg      s'    .IK1
H
I
6r   rg   c                   h    e Zd Z G d d      Zd Zd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zy)FindSpecTestsc                       e Zd Zedd       Zy)FindSpecTests.FakeMetaFinderNc                     | ||fS r%   r   )r<   pathtargets      r   	find_specz&FindSpecTests.FakeMetaFinder.find_spec   s    <@$<N5Nr   )NN)r   r   r   staticmethodr   r   r   r   FakeMetaFinderr      s    	N 
Nr   r   c                 ^   d}t        j                  |      5  t        j                  |      }d}| j                  j                  ||      }||_        ||_        |t        j                  |<   | j                   j                  |      }| j                  ||       d d d        y # 1 sw Y   y xY wNsome_modz	a loader!)r   uncacher:   r;   r*   r+   rP   rL   sysmodulesr   r   r   r<   r&   rQ   r0   founds         r   test_sys_moduleszFindSpecTests.test_sys_modules   s    \\$ 	*%%d+F F>>,,T6:D &F"FO &CKKII''-EUD)	* 	* 	*s   BB##B,c                 T   d}t        j                  |      5  t        j                  |      }|`d}| j
                  j                  ||      }||_        |t        j                  |<   | j                   j                  |      }| j                  ||       d d d        y # 1 sw Y   y xY wr   )r   r   r:   r;   rP   r*   r+   rL   r   r   r   r   r   s         r   #test_sys_modules_without___loader__z1FindSpecTests.test_sys_modules_without___loader__   s    \\$ 	*%%d+F! F>>,,T6:D"FO &CKKII''-EUD)	* 	* 	*s   A=BB'c                 D   d}t        j                  |      5  t        j                  |      }d |_        |t
        j                  |<   | 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Nr   )
r   r   r:   r;   rL   r   r   r,   
ValueErrorr   r   r<   r&   s      r   test_sys_modules_spec_is_Nonez+FindSpecTests.test_sys_modules_spec_is_None   s    \\$ 	*%%d+F"FO &CKK"":. *		##D)*		* 	** *		* 	*s$   ABB
9B
B	BBc                 L   d}t        j                  |      5  t        j                  |      }| j                  j                  |d       }||_        |t        j                  |<   | j                   j                  |      }| j                  ||       d d d        y # 1 sw Y   y xY wr   )r   r   r:   r;   r*   r+   rL   r   r   r   r   )r   r<   r&   r0   r   s        r   test_sys_modules_loader_is_Nonez-FindSpecTests.test_sys_modules_loader_is_None   s    \\$ 	*%%d+F>>,,T48D"FO &CKKII''-EUD)	* 	* 	*s   A9BB#c                 Z   d}t        j                  |      5  t        j                  |      }	 |`|t        j                  |<   | j                  t              5  | j                   j                  |       d d d        d d d        y # t
        $ r Y `w xY w# 1 sw Y   !xY w# 1 sw Y   y xY wr   )r   r   r:   r;   rL   AttributeErrorr   r   r,   r   r   r   s      r    test_sys_modules_spec_is_not_setz.FindSpecTests.test_sys_modules_spec_is_not_set   s    \\$ 	*%%d+FO !'CKK"":. *		##D)*	* 	* " * *	* 	*sE   B!B(B!B5B!	BB!BB!B	B!!B*c                 $   d}t        j                  |      5  t        j                  | j                  g      5  | j	                  |d d f| j                   j                  |             d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr   )	meta_path)r   r   import_stater   r   r   )r   r<   s     r   test_successzFindSpecTests.test_success   s    \\$ 	<""d.A.A-BC <  $d!3!%!4!4T!:<<	< 	<< <	< 	<s"   "B/A:)B:B	?BBc                 X    | j                  | j                  j                  d             y )Nnevergoingtofindthismodule)assertIsNoner   r   rl   s    r   test_nothingzFindSpecTests.test_nothing   s     $))--.JKLr   c                    d}d}t        j                  |d      5 }t        j                  |||      \  }}| j                   j                  |      }| j	                  |d        | j                  |t        t        j                               | j                  |t        t        j                               | j                   j                  |      }| j                  ||       d d d        y # 1 sw Y   y xY wNro   hamTpkgr   temp_module	submoduler   assertIsNotassertInsortedr   r   assertNotInr   r   r<   subnamepkg_dirfullname_r0   
spec_agains           r   test_find_submodulez!FindSpecTests.test_find_submodule   s    d- 	/..w@KHa99&&x0DT4(MM$s{{ 34Xvckk':;,,X6JZ.	/ 	/ 	/s   CC,,C5c                 &   d}d}t        j                  |d      5 }| j                  j                  |       t        j                  |||      \  }}| j                   j                  |      }| j                  |d        | j                  |t        t        j                               | j                  |t        t        j                               | j                   j                  |      }| j                  ||       d d d        y # 1 sw Y   y xY wr   )r   r   initimport_moduler   r   r   r   r   r   r   r   r   r   s           r   +test_find_submodule_parent_already_importedz9FindSpecTests.test_find_submodule_parent_already_imported  s    d- 		/II##D)..w@KHa99&&x0DT4(MM$s{{ 34Xvckk':;,,X6JZ.		/ 		/ 		/s   C"DDc                    d}d}t        j                  |d      5 }t        j                  |||      \  }}d|z   }| j                   j                  ||      }| j	                  |d        | j                  |t        t        j                               | j                  |t        t        j                               | j                   j                  |      }| j                  ||       d d d        y # 1 sw Y   y xY wNro   r   Tr   .r   )	r   r<   r   r   r   r   relnamer0   r   s	            r   test_find_relative_modulez'FindSpecTests.test_find_relative_module  s    d- 		/..w@KHaGmG99&&w5DT4(MM$s{{ 34Xvckk':;,,X6JZ.		/ 		/ 		/s   CC22C;c                    d}d}t        j                  |d      5 }t        j                  |||      \  }}d|z   }| j                  t              5  | j                   j                  |       d d d        | j                  |t        t        j                               | j                  |t        t        j                               d d d        y # 1 sw Y   dxY w# 1 sw Y   y xY wr   )
r   r   r   r,   r-   r   r   r   r   r   )r   r<   r   r   r   r   r   s          r   )test_find_relative_module_missing_packagez7FindSpecTests.test_find_relative_module_missing_package"  s    d- 	<..w@KHaGmG"";/ -		##G,-T6#++#67Xvckk':;	< 	<- -	< 	<s$   5CC-ACC	CC%c                     | j                  t              5  | j                  j                  d       d d d        y # 1 sw Y   y xY w)Nzmodule.name)r,   ModuleNotFoundErrorr   r   rl   s    r   test_find_submodule_in_modulez+FindSpecTests.test_find_submodule_in_module-  s:     23 	/II.	/ 	/ 	/	   ;AN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      sK    O O
*
***
*<M///	</r   r   )r   r   r*   c                       e Zd Zd Zd Zy)MagicNumberTestsc                 b    | j                  t        | j                  j                        d       y )N   )r   lenr   MAGIC_NUMBERrl   s    r   test_lengthzMagicNumberTests.test_length<  s!    TYY334a8r   c                 l    | j                  | j                  j                  j                  d             y )Ns   
)
assertTruer   r   endswithrl   s    r   test_incorporates_rnz%MagicNumberTests.test_incorporates_rn@  s#    		..77@Ar   N)r   r   r   r   r   r   r   r   r   r   :  s    9Br   r   c                      e Zd ZdZej
                  j                  Z ej                  ej
                  j                  du d      d        Z
d Zd Zd Zd Zd	 Zd
 Zd Zd Zd Z ej(                  ej,                  dk(  xr ej.                  dk(  d      d        Z ej                  ej
                  j                  du d      d        Z ej                  ej
                  j                  du d      d        Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z# ej                  ej
                  j                  du d      d        Z$ ej                  ej
                  j                  du d      d        Z% ej                  ej
                  j                  du d      d         Z& ej                  ej
                  j                  du d      d!        Z' ej                  ej
                  j                  du d      d"        Z(y)#PEP3147TestszMTests of PEP 3147-related functions: cache_from_source and source_from_cache.Nz1requires sys.implementation.cache_tag not be Nonec           	         t         j                  j                  dddd      }t         j                  j                  dddddj                  | j                              }| j                  | j                  j                  |d      |       y 	Nfoobarbazqux.py__pycache__
qux.{}.pycrs   optimizationosr   r   formattagr   r   cache_from_sourcer   r   expects      r   test_cache_from_sourcez#PEP3147Tests.test_cache_from_sourceP  so    
 ww||E5%:eUE=*11$((;=44T4K	!r   c                    t        j                  t        j                  dd       5  | j	                  t
              5  | j                  j                  d       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)N	cache_tagzwhatever.py)r   	swap_attrr   implementationr,   NotImplementedErrorr   r   rl   s    r   #test_cache_from_source_no_cache_tagz0PEP3147Tests.test_cache_from_source_no_cache_tag[  sj    s11;E 	;""#67 ;		++M:;	; 	;; ;	; 	;s"   A5A)A5)A2	.A55A>c                    t         j                  j                  dd      }t         j                  j                  dddj                  | j                              }| j                  | j                  j                  |d      |       y )Nzfoo.barfiler   z
file{}.pycrs   r   r   r   s      r   test_cache_from_source_no_dotz*PEP3147Tests.test_cache_from_source_no_dota  se    ww||Iv.i*11$((;=44T4K	!r   c                 t   t         j                  j                  dddd      }t        j                         5  t        j
                  d       | j                  | j                  j                  |d      | j                  j                  |d             | j                  | j                  j                  |d	      | j                  j                  |d
             d d d        t        j                         5  t        j
                  d       | j                  t              5  | j                  j                  |d       d d d        | j                  t              5  | j                  j                  |d	       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   XxY w# 1 sw Y   *xY w# 1 sw Y   y xY w)Nr   r   r   r   ignoreF   r   Trs   error)r   r   r   warningscatch_warningssimplefilterr   r   r   r,   DeprecationWarningr   r   s     r   %test_cache_from_source_debug_overridez2PEP3147Tests.test_cache_from_source_debug_overridei  sg    ww||E5%:$$& 	Q!!(+TYY88uE!YY88A8NPTYY88tD!YY88B8OQ		Q $$& 	8!!'*""#56 9		++D%89""#56 8		++D$78		8 	8	Q 	Q9 98 8		8 	8sH   B$F
7+F."F?F.F"9F.
FF	F."F+	'F..F7c                     d}t         j                  j                  ddj                  | j                              }| j                  | j                  j                  |d      |       y Nfoo.pyr   z
foo.{}.pycrs   r   r   r   s      r   test_cache_from_source_cwdz'PEP3147Tests.test_cache_from_source_cwdz  sQ    m\-@-@-JK44T4K	!r   c                    t         j                  j                  ddd      } G d d      }t        j                         5  t        j
                  d       | j                  | j                  j                  |g       | j                  j                  |d             | j                  | j                  j                  |d	g      | j                  j                  |d
             | j                  t              5  | j                  j                  d |              d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr   r   zbaz.pyc                       e Zd Zd Zy)=PEP3147Tests.test_cache_from_source_override.<locals>.Bearishc                     t         r%   )RuntimeErrorrl   s    r   __bool__zFPEP3147Tests.test_cache_from_source_override.<locals>.Bearish.__bool__  s    l 2r   N)r   r   r   r  r   r   r   Bearishr    s    2r   r  r   r   r      rs   z/foo/bar/baz.py)r   r   r   r   r   r   r   r   r   r,   r  )r   r   r  s      r   test_cache_from_source_overridez,PEP3147Tests.test_cache_from_source_override  s    ww||E5(3	3 	3$$& 	J!!(+TYY88rB!YY88A8NPTYY88tD!YY88B8OQ""<0 J		++,=wyIJ	J 	JJ J	J 	Js%    B:D9:"D-D9-D6	2D99Ec                     d}t         j                  j                  ddj                  | j                              }| j                  | j                  j                  |d      |       y r   r   r   s      r   0test_cache_from_source_optimization_empty_stringz=PEP3147Tests.test_cache_from_source_optimization_empty_string  sQ    m\-@-@-JK44T4K	!r   c                    d}t         j                  j                  }t        j                  j                  ddj                  | j                              }|dk(  r|dz   }n<|dk  r|dj                  |      z   }n"dj                  |      }| j                  |       | j                  | j                  j                  |d 	             y )
Nr   r   foo.{}r   .pyc   .opt-{}.pycz){!r} is a non-standard optimization levelr   )r   flagsoptimizer   r   r   r   r   skipTestr   r   r   )r   r   optimization_levelalmost_expectr   msgs         r   (test_cache_from_source_optimization_Nonez5PEP3147Tests.test_cache_from_source_optimization_None  s      YY//]HOODHH4MN""V+F1$"]%9%9:L%MMF=DDEWXCMM#44T4M	!r   c                 ,   d}t         j                  t         j                  z   }t        j                  j                  ddj                  | j                              }| j                  j                  ||      }| j                  ||dj                  |      z          | j                  | j                  j                  |d      |dz          | j                  t              5  | j                  j                  |d       d d d        y # 1 sw Y   y xY w)	Nr   r   r  r   r  *   z.opt-42.pyczpath/is/bad)stringascii_lettersdigitsr   r   r   r   r   r   r   r   r,   r   )r   r   valid_charactersr  gots        r   'test_cache_from_source_optimization_setz4PEP3147Tests.test_cache_from_source_optimization_set  s     !//&--?]HOODHH4MNii))$=M)N&)=)=>N)OO	Q 	44T4K&6	8 z* 	JII''='I	J 	J 	Js   #D

Dc                    t        j                         5  t        j                  d       | j                  t              5  | j
                  j                  ddd       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr   r   Frs   r   )r   r   r   r,   	TypeErrorr   r   rl   s    r   ;test_cache_from_source_debug_override_optimization_both_setzHPEP3147Tests.test_cache_from_source_debug_override_optimization_both_set  s{    $$& 	N!!(+""9- N		++He"+MN	N 	NN N	N 	Ns#   +A< A0A<0A9	5A<<B\/z/test meaningful only where os.altsep is definedc                     | j                  | j                  j                  dd      dj                  | j                               y )Nz\foo\bar\baz/qux.pyrs   r   z#\foo\bar\baz\__pycache__\qux.{}.pyc)r   r   r   r   r   rl   s    r   )test_sep_altsep_and_sep_cache_from_sourcez6PEP3147Tests.test_sep_altsep_and_sep_cache_from_source  s=     	II''(@r'R6==dhhG	Ir   c           	         t        j                  dddd      }t        j                  j	                  dddddj                  | j                              }| j                  | j                  j                  |d      |       y r   )
pathlibPurePathr   r   r   r   r   r   r   r   r   s      r   $test_cache_from_source_path_like_argz1PEP3147Tests.test_cache_from_source_path_like_arg  sm     ueX>eUE=*11$((;=44T4K	!r   z4requires sys.implementation.cache_tag to not be Nonec           	         t         j                  j                  dddddj                  | j                              }t         j                  j                  dddd      }| j                  | j                  j                  |      |       y Nr   r   r   r   r   r   r   r   r   r   r   r   r   source_from_cacher   s      r   test_source_from_cachez#PEP3147Tests.test_source_from_cache  sg    
 ww||E5%(//9;eUE8<44T:FCr   c                 D   t         j                  j                  ddd      }t        j                  t
        j                  dd       5  | 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)Nblahr   zwhatever.pycr   )r   r   r   r   r   r   r   r,   r   r   r,  r   s     r   #test_source_from_cache_no_cache_tagz0PEP3147Tests.test_source_from_cache_no_cache_tag  s    ww||FM>Bs11;E 	2""#67 2		++D12	2 	22 2	2 	2s$   BB
9B
B	BBc                 Z    | j                  t        | j                  j                  d       y )Nz/foo/bar/bazqux.pycr,   r   r   r,  rl   s    r   test_source_from_cache_bad_pathz,PEP3147Tests.test_source_from_cache_bad_path  s%     			335J	Lr   c                 Z    | j                  t        | j                  j                  d       y )Nzfoo.cpython-32.pycr2  rl   s    r   test_source_from_cache_no_slashz,PEP3147Tests.test_source_from_cache_no_slash  s#    		335I	Kr   c                 Z    | j                  t        | j                  j                  d       y )Nz__pycache__/foo.pycr2  rl   s    r   #test_source_from_cache_too_few_dotsz0PEP3147Tests.test_source_from_cache_too_few_dots  s#    		335J	Lr   c                     | j                  t              5  | j                  j                  d       d d d        y # 1 sw Y   y xY w)Nz(__pycache__/foo.cpython-32.opt-1.foo.pycr2  rl   s    r   $test_source_from_cache_too_many_dotsz1PEP3147Tests.test_source_from_cache_too_many_dots  s?    z* 	@II''>@	@ 	@ 	@r   c                 Z    | j                  t        | j                  j                  d       y )Nz"__pycache__/foo.cpython-32.foo.pycr2  rl   s    r   test_source_from_cache_not_optz+PEP3147Tests.test_source_from_cache_not_opt  s"    		330	2r   c                 Z    | j                  t        | j                  j                  d       y )Nz/foo/bar/foo.cpython-32.foo.pycr2  rl   s    r   $test_source_from_cache_no__pycache__z1PEP3147Tests.test_source_from_cache_no__pycache__  s"    		33-	/r   c                     t         j                  j                  ddj                  | j                              }| j                  | j                  j                  |      d       y )Nr   zfoo.{}.opt-1.pycr   r+  r   s     r   )test_source_from_cache_optimized_bytecodez6PEP3147Tests.test_source_from_cache_optimized_bytecode  sE    ww||M+=+D+DTXX+NO44T:HEr   c                     t         j                  j                  ddj                  | j                              }| j                  t              5  | j                  j                  |       d d d        y # 1 sw Y   y xY w)Nr   zfoo.{}.opt-.pyc)	r   r   r   r   r   r,   r   r   r,  r   s     r   +test_source_from_cache_missing_optimizationz8PEP3147Tests.test_source_from_cache_missing_optimization	  s[    ww||M+<+C+CDHH+MNz* 	.II''-	. 	. 	.s   A44A=c           	         t        j                  dddddj                  | j                              }t        j
                  j                  dddd      }| j                  | j                  j                  |      |       y r*  )
r&  r'  r   r   r   r   r   r   r   r,  r   s      r   $test_source_from_cache_path_like_argz1PEP3147Tests.test_source_from_cache_path_like_arg  se     ue] , 3 3DHH =?eUE8<44T:FCr   c                    t         j                  j                  t         j                  j                  dd      t         j                  j                  t         j                  j                  dd      t         j                  j                  t         j                  j                  dd      t         j                  j                  z   g}d}t         j                  dk(  rd}|D cg c]  }| | 
 }}|dd	gz  }|D ]  }| j                  |
      5  |t         j                  j                  t         j                  j                  dddd      z   }t         j                  j                  |ddddj                  | j                              }t        j                  |      5  | j                  | j                  j                  |d      |       d d d        d d d         y c c}w # 1 sw Y   xY w# 1 sw Y   xY w)Ntmpbytecodeu   ☃ztrailing-slashrs   ntzC:z
\\?\C:\fooz\\localhost\c$\bar)r   r   r   r   r   r   r   )r   r   r   sepr<   subTestr   r   r   temporary_pycache_prefixr   r   )r   pycache_prefixesdriveprefixpycache_prefixr   r   s          r   .test_cache_from_source_respects_pycache_prefixz;PEP3147Tests.test_cache_from_source_respects_pycache_prefix  s    GGLLeZ8GGLLeX6GGLLe-=>L

 77d?E1A C'-5'&" C  C0E FF. 
	 N>2 	 rww||GGKKuh @ @"E5% ''13 22>B  $$		33Dr3J  	  	 
	  C   	  	 s+   !GBG0.G$G0$G-)G00G:	c           
         t         j                  j                  t         j                  j                  dd      }t         j                  j                  dddd      }t         j                  j	                  t        j
                               d   t         j                  j                  z   }t         j                  j                  |t         j                  j                  t        j
                         |      dddd| j                   d	      }t        j                  |      5  | j                  | j                  j                  |d
      t         j                  j                  |             d d d        y # 1 sw Y   y xY w)NrE  rF  r   r   r   r   r   qux.r  rs   r   )r   r   r   rH  
splitdrivegetcwdrelpathr   r   rJ  r   r   normpath)r   rN  r   rootr   s        r   7test_cache_from_source_respects_pycache_prefix_relativezDPEP3147Tests.test_cache_from_source_respects_pycache_prefix_relative4  s    bggkk5*Eww||E5%:ww!!"))+.q1BGGKK?GGOOBIIK.5%4z!68 **>: 	*		++Dr+B  (*	* 	* 	*s   "AE66E?c           	         t         j                  j                  t         j                  j                  dd      }t         j                  j                  |dddd| j                   d      }t         j                  j                  t         j                  j                  dddd      }t        j                  |      5  | j                  | j
                  j                  |      |       d d d        y # 1 sw Y   y xY w)	NrE  rF  r   r   r   rQ  r  r   	r   r   r   rH  r   r   rJ  r   r,  r   rN  r   r   s       r   ,test_source_from_cache_inside_pycache_prefixz9PEP3147Tests.test_source_from_cache_inside_pycache_prefixF  s     bggkk5*Eww||NE5%"488*D13bggkk5%I**>: 	HTYY88>G	H 	H 	Hs   ;,C00C9c           	         t         j                  j                  t         j                  j                  dd      }t         j                  j                  ddddd| j                   d      }t         j                  j                  dddd	      }t        j                  |      5  | j                  | j
                  j                  |      |       d d d        y # 1 sw Y   y xY w)
NrE  rF  r   r   r   r   rQ  r  r   rY  rZ  s       r   -test_source_from_cache_outside_pycache_prefixz:PEP3147Tests.test_source_from_cache_outside_pycache_prefixS  s     bggkk5*Eww||E5%"488*D13eUE8<**>: 	HTYY88>G	H 	H 	Hs   ",CC ))r   r   r   r   r   r   r   r   unittestskipIfr   r   r   r   r   r  r	  r  r  r   
skipUnlessr   rH  altsepr$  r(  r-  r0  r3  r5  r7  r9  r;  r=  r?  rA  rC  rO  rW  r[  r]  r   r   r   r   r   J  sv   W



&
&CX__S''11T9HJ!J!;!8"!J$!! J"N X4<BII,<FHIHI X__S''11T9HJ!J! X__S''11T9KMDMD2LK
L
@
2/F
. X__S''11T9KMDMD X__S''11T9KM M 6 X__S''11T9KM*M*  X__S''11T9KM	HM	H X__S''11T9KM	HM	Hr   r   c                   n    e Zd ZdZ ej
                  ej                  j                  dv d      d        Z	y)r   zA
    Test release compatibility issues relating to importlib
    )	candidatefinalz8only applies to candidate or final python release levelsc                     d}t         j                  t        j                  j                  d d d      }d}| j                  |||       y )Ni  r  littlea  To avoid breaking backwards compatibility with cached bytecode files that can't be automatically regenerated by the current user, candidate and final releases require the current  importlib.util.MAGIC_NUMBER to match the expected magic number in this test. Set the expected magic number in this test to the current MAGIC_NUMBER to continue with the release.

Changing the MAGIC_NUMBER for a maintenance release requires discussion in python-dev and notification of community stakeholders.)int
from_bytesr   r   r   r   )r   EXPECTED_MAGIC_NUMBERactualr  s       r   test_magic_numberz"MagicNumberTests.test_magic_numberj  sJ    & !%	 ; ;BQ ?J	& 	 	.<r   N)
r   r   r   r   r^  r`  r   version_inforeleaselevelrk  r   r   r   r   r   f  s@     X%%)??B=	=r   zsubinterpreters requiredc                       e Zd Z ej                  d      Zd Zd Z ej                  e
du d      d        Z ej                  edu d      d        Z ej                  edu d      d	        Zy)
,IncompatibleExtensionModuleRestrictionsTestszO^<class 'ImportError'>: module (.*) does not support loading in subinterpretersc                 $   t        j                  d      }	 t        j                  ||       y # t         j                  $ rM}| j                  j                  t        |            x}r|j                         \  }t        |      Y d }~y d }~ww xY w)NTisolated	_interpreterscreate
run_stringRunFailedErrorERRORmatchstrgroupsr-   r   scriptinterpidexcmmodnames         r   run_with_own_gilz=IncompatibleExtensionModuleRestrictionsTests.run_with_own_gil  sx     ''6	+$$Xv6++ 	+JJ$$SX..q.88:!'** /	+   / BAB

Bc                 $   t        j                  d      }	 t        j                  ||       y # t         j                  $ rM}| j                  j                  t        |            x}r|j                         \  }t        |      Y d }~y d }~ww xY w)NFrq  rs  r|  s         r   run_with_shared_gilz@IncompatibleExtensionModuleRestrictionsTests.run_with_shared_gil  sx     ''7	+$$Xv6++ 	+JJ$$SX..q.88:!'** /	+r  Nz%test requires _testsinglephase modulec                    t        j                  d      }| j                  d      5  | j                  |       d d d        | j                  d      5  | j	                  |       d d d        t        j                  d      }| j                  d      5  | j                  t              5  | j                  |       d d d        d d d        | j                  d      5  | j                  t              5  | 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   sxY w# 1 sw Y   wxY w# 1 sw Y   BxY w# 1 sw Y   y xY w)Nz
            from importlib.util import _incompatible_extension_module_restrictions
            with _incompatible_extension_module_restrictions(disable_check=True):
                import _testsinglephase
            check disabled, shared GIL#check disabled, per-interpreter GILz
            from importlib.util import _incompatible_extension_module_restrictions
            with _incompatible_extension_module_restrictions(disable_check=False):
                import _testsinglephase
            check enabled, shared GIL"check enabled, per-interpreter GIL)textwrapdedentrI  r  r  r,   r-   r   r}  s     r   test_single_phase_init_modulezJIncompatibleExtensionModuleRestrictionsTests.test_single_phase_init_module  s;    " 
 \\67 	-$$V,	-\\?@ 	*!!&)	*  & 
 \\56 	1"";/ 1((01	1 \\>? 	."";/ .%%f-.	. 	.	- 	-	* 	*1 1	1 	1. .	. 	.s_   DD D8(D,:D8E1EED D),D5	1D88EE		EEz$test requires _testmultiphase modulec                    t        j                  dt        j                  d      }|t        j                  d      z   }| j	                  d      5  | j                  |       d d d        | j	                  d      5  | j                  |       d d d        |t        j                  d      z   }| j	                  d      5  | j                  |       d d d        | j	                  d      5  | j                  t              5  | 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   kxY w# 1 sw Y   6xY w# 1 sw Y   y xY w)	Nz
            from importlib.util import spec_from_loader, module_from_spec
            from importlib.machinery import ExtensionFileLoader

            name = '_test_shared_gil_only'
            filename = zy
            loader = ExtensionFileLoader(name, filename)
            spec = spec_from_loader(name, loader)

            a  
            from importlib.util import _incompatible_extension_module_restrictions
            with _incompatible_extension_module_restrictions(disable_check=True):
                module = module_from_spec(spec)
                loader.exec_module(module)
            r  r  a  
            from importlib.util import _incompatible_extension_module_restrictions
            with _incompatible_extension_module_restrictions(disable_check=False):
                module = module_from_spec(spec)
                loader.exec_module(module)
            r  r  )	r  r  _testmultiphaser`   rI  r  r  r,   r-   )r   	prescriptr}  s      r   'test_incomplete_multi_phase_init_modulezTIncompatibleExtensionModuleRestrictionsTests.test_incomplete_multi_phase_init_module  sQ   OO )
 (003 4	% 		 X__ .   \\67 	-$$V,	-\\?@ 	*!!&)	* X__ .   \\56 	-$$V,	-\\>? 	."";/ .%%f-.	. 	.	- 	-	* 	*	- 	-. .	. 	.sH   D#<D/?D;*E EE#D,/D8;EE	EEc                    t        j                  d      }| j                  d      5  | j                  |       d d d        | j                  d      5  | j	                  |       d d d        t        j                  d      }| j                  d      5  | j                  |       d d d        | j                  d      5  | j	                  |       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   MxY w# 1 sw Y   y xY w)Nz
            from importlib.util import _incompatible_extension_module_restrictions
            with _incompatible_extension_module_restrictions(disable_check=True):
                import _testmultiphase
            r  r  z
            from importlib.util import _incompatible_extension_module_restrictions
            with _incompatible_extension_module_restrictions(disable_check=False):
                import _testmultiphase
            r  r  )r  r  rI  r  r  r  s     r   %test_complete_multi_phase_init_modulezRIncompatibleExtensionModuleRestrictionsTests.test_complete_multi_phase_init_module  s     " 
 \\67 	-$$V,	-\\?@ 	*!!&)	*  & 
 \\56 	-$$V,	-\\>? 	*!!&)	* 	*	- 	-	* 	*	- 	-	* 	*s/   CC$C0=C<C!$C-0C9<D)r   r   r   recompilerx  r  r  r^  r_  _testsinglephaser  r  r  r  r   r   r   ro  ro    s     BJJhiE++ X__%-/VW. X.. X___,.TU!. V!.F X___,.TU* V*r   ro  __main__)3test.test_importlibr   import_importlibr8   r   r*   importlib_utilimportlib.utilr   r   r&  r  r  r   r)   r   r  r:   r^  unittest.mockr   r  r-   r  _xxsubinterpretersrt  r   r   	test_bothFrozen_DecodeSourceBytesTestsSource_DecodeSourceBytesTestsr    Frozen_ModuleFromSpecTestsSource_ModuleFromSpecTestsrg   Frozen_ResolveNameTestsSource_ResolveNameTestsr   Frozen_FindSpecTestsSource_FindSpecTestsr   Frozen_MagicNumberTestsSource_MagicNumberTestsr   Frozen_PEP3147TestsSource_PEP3147TestsTestCaser_  ro  r   mainr   r   r   <module>r     sB   $dO,t[)!D!!"78	&&&'78  	  	  
      .
@ @. T^^*@F9 F9T DNN&C9&(
6 6F T^^$>:@/ @/J T^^M>#,.
B B T^^$>:TH THr T^^L~6&=x(( &=R $&(BCf*83D3D f* Df*R zHMMO E    O  Ms6   F4 G G 4F?>F?GGGG