
    <e_[                     t   d dl mZ d dlmZmZ d dlm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 G d dej                  Z G d d	ej                  Z G d
 dej                  Z G d dej                  Z G d dej                  Zd Zedk    r ej                     dS dS )    )Path)unloadCleanImport)check_warningsN)spec_from_file_locationc                   J    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )PkgutilTestsc                     t          j                    | _        |                     t          j        | j                   t          j                            d| j                   d S Nr   )	tempfilemkdtempdirname
addCleanupshutilrmtreesyspathinsertselfs    (/usr/lib/python3.11/test/test_pkgutil.pysetUpzPkgutilTests.setUp   sH    '))t|4444<(((((    c                      t           j        d= d S r   )r   r   r   s    r   tearDownzPkgutilTests.tearDown   s    HQKKKr   c                    d}d}t           j                            | j        |          }t          j        |           t          t           j                            |d          d          }|                                 t          t           j                            |d          d          }|                    |           |                                 t          j        t           j                            |d                     t          t           j                            |dd          d          }|                    |           |                                 t          j	        |d          }| 
                    ||           t          j	        |d          }| 
                    ||           t          j        |= d S )Ntest_getdata_filesys%   Hello, world!
Second line
Third line__init__.pywbres.txtsubsub/res.txt)osr   joinr   mkdiropenclosewritepkgutilget_dataassertEqualr   modules)r   pkgRESOURCE_DATApackage_dirfres1res2s          r   r   z!PkgutilTests.test_getdata_filesys   sd   $ D gll4<55
k=994@@				k955t<<					
k511222k5)<<dCC					 Y//}---]33}---Kr   c                 :   d}d}d}t           j                            | j        |          }t	          j        |d          }|                    |dz   d           |                    |dz   |           |                    |dz   |           |                                 t          j        	                    d	|           t          j        |d
          }|                     ||           t          j        |d          }|                     ||           g }t          j        |g          D ]<}	|                     |	t          j                   |                    |	j                   =|                     |dg           t          j        d	= t          j        |= d S )Ntest_getdata_zipfile.ziptest_getdata_zipfiler   w/__init__.py /res.txtz/sub/res.txtr   r!   r#   )r$   r   r%   r   zipfileZipFilewritestrr(   r   r   r*   r+   r,   iter_modulesassertIsInstance
ModuleInfoappendnamer-   )
r   zipr.   r/   zip_filezr2   r3   names
moduleinfos
             r   r6   z!PkgutilTests.test_getdata_zipfile<   s   ($ D 7<<c22OHc** 	


3',,,	

3#]333	

3'777				 	8$$$Y//}---]33}---!.z:: 	* 	*J!!*g.@AAALL))))!7 8999HQKKr   c                    d}d}d}t           j                            | j        |          }t	          j        |d          }|                    |dz   d           |                    |dz   |           |                                 t          j        	                    d|           	 t          j        |d	          }|                     ||           g }t          j        t          |          g          D ]<}|                     |t          j                   |                    |j                   =|                     ||g           t          j        d= t          j                            |d            n2# t          j        d= t          j                            |d            w xY wd
}	|                     t,          |	          5  t/          t          j        d                     d d d            d S # 1 swxY w Y   d S )Nr5   r6   r   r7   r8   r9   r:   r   r!   z9path must be None or list of paths to look for modules ininvalid_path)r$   r   r%   r   r;   r<   r=   r(   r   r   r*   r+   r,   r>   r   r?   r@   rA   rB   r-   popassertRaisesRegex
ValueErrorlist)
r   rC   r.   r/   rD   rE   resrF   rG   expected_msgs
             r   test_issue44061_iter_modulesz)PkgutilTests.test_issue44061_iter_modules_   s   ($ D 7<<c22OHc** 	


3',,,	

3#]333				 	8$$$	'"3	22CS-000 E%2DNN3CDD . .
%%j'2DEEEZ_----USE***KOOC&&&& KOOC&&&& S##J== 	7 	7%n55666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   (B#E9 9/F("G77G;>G;c                 $   d}t           j                            | j        |          }t          j        |d           |                     t           j        |           t          j        | j        g          D ]}| 	                    d           d S )Nunreadable_packager   )r   zunexpected package found)
r$   r   r%   r   r&   r   rmdirr*   walk_packagesfail)r   package_namedts       r   test_unreadable_dir_on_syspathz+PkgutilTests.test_unreadable_dir_on_syspath   s    +GLL|44 	A!$$$&T\N;;; 	2 	2AII01111	2 	2r   c                    d}t           j                            | j        |          }t          j        |           t          t           j                            |d          d          }|                                 t          j        t           j                            |d                     t          t           j                            |dd          d          }|                                 t          t           j                            |dd          d          }|                                 d}t           j                            | j        |          }t          j        |           t          t           j                            |d          d          }|                                 t          j        t           j                            |d                     t          t           j                            |dd          d          }|                                 t          t           j                            |dd          d          }|                                 g d}d t          j        | j        g          D             }| 	                    ||           |D ]%}|
                    d          rt          j        |= &d S )	Ntest_walkpackages_filesysr   r    r"   zmod.py)r"   zsub.test_walkpackages_filesysz!sub.test_walkpackages_filesys.modr[   ztest_walkpackages_filesys.subz!test_walkpackages_filesys.sub.modc                     g | ]
}|d          S     .0es     r   
<listcomp>z:PkgutilTests.test_walkpackages_filesys.<locals>.<listcomp>   s    EEE!1EEEr   mod)r$   r   r%   r   r&   r'   r(   r*   rT   r,   endswithr   r-   )	r   pkg1pkg1_dirr1   pkg2pkg2_direxpectedactualr.   s	            r   r[   z&PkgutilTests.test_walkpackages_filesys   s:   *7<<d33
h66==				
h..///h}==tDD				hx88$??				 7<<d33
h66==				
h(CDDEEEh(C]SSUYZZ				h(CXNNPTUU				
 
 
 FEw4dl^DDEEE*** 	! 	!C||E"" C  	! 	!r   c                 (   	 d}d}d}t           j                            | j        |          }t	          j        |d          }|                    |dz   d           |                    |dz   |z   dz   d           |                    |dz   |z   dz   d           |                    |dz   d           |                    |dz   |z   dz   d           |                    |dz   |z   dz   d           |                                 t          j        	                    d	|           g d
}d t          j        |g          D             }|                     ||           t          j        d	= |D ]%}|                    d          rt          j        |= &d S )Nztest_walkpackages_zipfile.ziptest_walkpackages_zipfiler"   r7   r8   r9   /z/mod.pyr   )r"   zsub.test_walkpackages_zipfilez!sub.test_walkpackages_zipfile.modrm   ztest_walkpackages_zipfile.subz!test_walkpackages_zipfile.sub.modc                     g | ]
}|d          S r]   r_   r`   s     r   rc   z:PkgutilTests.test_walkpackages_zipfile.<locals>.<listcomp>   s    AAA!1AAAr   rd   )r$   r   r%   r   r;   r<   r=   r(   r   r   r*   rT   r,   re   r-   )	r   rC   rf   rh   rD   rE   rj   rk   r.   s	            r   rm   z&PkgutilTests.test_walkpackages_zipfile   s   P-*7<<c22OHc**	

4.("---	

4#:$~5r:::	

4#:$y0"555	

4.("---	

4#:$~5r:::	

4#:$y0"555				8$$$
 
 
 BAw4hZ@@AAA***HQK 	! 	!C||E"" C  	! 	!r   c                 x   d}|                      t          t          f          5  t          t	          j        |                     d d d            n# 1 swxY w Y   d}|                      t          t          f          5  t          t	          j        |                     d d d            d S # 1 swxY w Y   d S )Ntest_dirs   test_dir)assertRaises	TypeErrorrL   rM   r*   rT   )r   	str_inputbytes_inputs      r   2test_walk_packages_raises_on_string_or_bytes_inputz?PkgutilTests.test_walk_packages_raises_on_string_or_bytes_input   s+   		:677 	3 	3&y11222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 "	:677 	5 	5&{33444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s#   "AAA "B//B36B3c                    dd l }dd l}dt          fdt          j        fdt          j        j        fd|fd|fd|j        fd|j        fd	|j        j        fd
|j        j        fd|j        j        j        fd|j        j        j        fdt          fdt          fdt          j	        fdt          j	        fdt          fdt          fdt          j        ff}d t          fdt          fdt          fdt          fdt          fdt          fdt          fdt          fdt          fdt          fdt          fdt          fdt          fd t          fd!t          fd"t          fd#t          ff}d$}|D ]}t          j                            | j        |          }	 t          j        |d%           n# t$          $ r Y Lw xY wt          j                            |d&          }t'          |d'          5 }|                    d           |                                 d d d            n# 1 swxY w Y   t-          j                     t-          j        |          }|||ffz  }t3          |          dk    r||d d(         t          ffz  }|d)t          ffz  }|D ]]\  }	}
|                     |	*          5  t7          j        |	          }|                     ||
           d d d            n# 1 swxY w Y   ^|D ]t\  }	}|                     |	*          5  |                     |          5  t7          j        |	           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   ud S )+Nr   r$   zos.pathzos.path:pathseploggingzlogging:zlogging.handlerszlogging.handlers:zlogging.handlers:SysLogHandlerzlogging.handlers.SysLogHandlerz(logging.handlers:SysLogHandler.LOG_ALERTz(logging.handlers.SysLogHandler.LOG_ALERTzbuiltins.intzbuiltins:intzbuiltins.int.from_byteszbuiltins:int.from_byteszbuiltins.ZeroDivisionErrorzbuiltins:ZeroDivisionErrorzos:pathr^   g       @Tr9   z?abczabc/foofoozos.foozos.foo:zos.pth:pathsepzlogging.handlers:NoSuchHandlerz,logging.handlers:SysLogHandler.NO_SUCH_VALUEz,logging.handlers.SysLogHandler.NO_SUCH_VALUEZeroDivisionErrorzos.path.9abc9abc)	u	   वमस   é   Èu   안녕하세요u   さよならu   ありがとうu   Хорошоu   спасибоu   现代汉语常用字表exist_okr   r7   u   ०वमस)s)rx   logging.handlersr$   r   pathsephandlersSysLogHandler	LOG_ALERTint
from_bytesrz   rs   rL   ImportErrorAttributeErrorr%   r   makedirsUnicodeEncodeErrorr'   r)   flush	importlibinvalidate_cachesimport_modulelensubTestr*   resolve_namer,   rr   )r   rx   success_casesfailure_casesunicode_wordsuwrW   r1   rd   r   rj   oexcs                r   test_name_resolutionz!PkgutilTests.test_name_resolution   s    2J 0 !!12 '"23-w/?/MN-w/?/MN7 .8:7 .8:S!S!&7&7)+<=)+<= )
0 9	N)9Z 
#K ~&${+-~>;^L;^L +.Z(Z #
,M   	9 	9BT\2..AA-----&    Q..Aa 			              
 '))))"--Cb#YZ'M2ww{{"SbS';!7!88 	4jABB( 	. 	.KAx"" . .(++  H---. . . . . . . . . . . . . . . $ 	, 	,FAs"" , ,&&s++ , ,(+++, , , , , , , , , , , , , , ,, , , , , , , , , , , , , , ,	, 	,sl   F
F('F(*HH	H	+KK	K	?ML6*M6L::M=L:>MM	M	N)__name__
__module____qualname__r   r   r   r6   rP   rY   r[   rm   rv   r   r_   r   r   r	   r	      s        ) ) )
    :! ! !F%7 %7 %7N	2 	2 	2&! &! &!P!! !! !!F5 5 5Y, Y, Y, Y, Y,r   r	   c                   ^    e Zd Z G d de          Z G d de          Zd Zd Zd Zd Z	d	S )
PkgutilPEP302Testsc                        e Zd Zd Zd Zd ZdS )PkgutilPEP302Tests.MyTestLoaderc                     d S Nr_   )r   specs     r   create_modulez-PkgutilPEP302Tests.MyTestLoader.create_moduleE  s    4r   c                 R    |j                             dd          dz   |j         d<   d S )Nloadsr   r^   )__dict__get)r   rd   s     r   exec_modulez+PkgutilPEP302Tests.MyTestLoader.exec_moduleH  s+    $'L$4$4Wa$@$@1$DCL!!!r   c                     dS )NHello, world!r_   )r   r   s     r   r+   z(PkgutilPEP302Tests.MyTestLoader.get_dataL  s    "?r   N)r   r   r   r   r   r+   r_   r   r   MyTestLoaderr   D  sD        	 	 		E 	E 	E	# 	# 	# 	# 	#r   r   c                       e Zd ZddZdS )!PkgutilPEP302Tests.MyTestImporterNc                 t    t                                           }t          |d|j        j        z  |g           S )Nz<%s>)loadersubmodule_search_locations)r   r   r   	__class__r   )r   fullnamer   targetr   s        r   	find_specz+PkgutilPEP302Tests.MyTestImporter.find_specP  sD    '4466F*8+1F4D4M+M28FHJ J J Jr   )NN)r   r   r   r   r_   r   r   MyTestImporterr   O  s.        	J 	J 	J 	J 	J 	Jr   r   c                 j    t           j                            d|                                            d S r   )r   	meta_pathr   r   r   s    r   r   zPkgutilPEP302Tests.setUpW  s,    Q 3 3 5 566666r   c                      t           j        d= d S r   )r   r   r   s    r   r   zPkgutilPEP302Tests.tearDownZ  s    M!r   c                 r    |                      t          j        dd          d           t          j        d= d S )Nry   dummyr   )r,   r*   r+   r   r-   r   s    r   test_getdata_pep302z&PkgutilPEP302Tests.test_getdata_pep302]  s5    )%99?KKKKr   c                     dd l }|                     |j        d           |                     t          j        dd          d           |                     |j        d           t
          j        d= d S )Nr   r^   ry   r   r   )ry   r,   r   r*   r+   r   r-   )r   ry   s     r   test_alreadyloadedz%PkgutilPEP302Tests.test_alreadyloadedb  sp     	


A&&&)%99?KKKA&&&Kr   N)
r   r   r   objectr   r   r   r   r   r   r_   r   r   r   r   B  s        	# 	# 	# 	# 	#v 	# 	# 	#J J J J J J J J7 7 7    
    r   r   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )ExtendPathTestsc                    t          j                    }t          j                            d|           t
          j                            ||          }t          j        |           t          t
          j                            |d          d          5 }|	                    d           d d d            n# 1 swxY w Y   |S )Nr   r   r7   zKfrom pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
)
r   r   r   r   r   r$   r%   r&   r'   r)   )r   pkgnamer   pkgdirfls        r   create_initzExtendPathTests.create_initp  s    "$$7###gw//
"',,v}55s;; 	frHHdeee	f 	f 	f 	f 	f 	f 	f 	f 	f 	f 	f 	f 	f 	f 	f s   B88B<?B<c                     t           j                            |||dz             }t          |d          5 }t	          d                    |          |           d d d            d S # 1 swxY w Y   d S )N.pyr7   zvalue={})file)r$   r   r%   r'   printformat)r   r   r   submodule_namevaluemodule_namer   s          r   create_submodulez ExtendPathTests.create_submodule{  s    gll7G^e5KLL+s## 	5r*##E**4444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s   %A''A+.A+c           
         d}|                      |          }|                      |          }|                     ||dd           |                     ||dd           dd l}dd l}|                     |j        j        d           |                     |j        j        d           |                     t          |j	                  t          t          j                            ||          t          j                            ||          g                     t          j        |           t          j        |           t          j        d= t          j        d= t          j        d= t          j        d= t          j        d= d S )Nry   barr   bazr^   foo.barfoo.baz)r   r   foo.barfoo.bazr,   r   r   r   sorted__path__r$   r   r%   r   r   r   r-   r   r   	dirname_0	dirname_1ry   s        r   test_simplezExtendPathTests.test_simple  sb   $$W--	$$W--	i%;;;i%;;;****** 	--i!A!A!#i!A!A!C D D	E 	E 	E
 	i   i   HQKHQKKK	"K	"""r   c                    t           j        }t           j        }d}d}|                     |          }t          j                            ||          }d                    ||          }t          j	        
                    |d            t          j	        
                    |d            	 |                     |||d           t          j        |           t           ||                    } ||          }	|D ]}
t          j        |
|          }|j        }	 |j        }n# t"          $ r Y nw xY w|                     |
t          j        j                   |                     |
|	           |                     |t          j        j                   |                     t          j        |
|                     |                     t2                    5  t           |d                     d d d            n# 1 swxY w Y   |                     t2                    5  t           |d                     d d d            n# 1 swxY w Y   t5          j        |           t          j        d= 	 t          j	        d= t          j	        d= d S # t8          $ r Y d S w xY w# t5          j        |           t          j        d= 	 t          j	        d= t          j	        d= w # t8          $ r Y w w xY wxY w)Nspameggsz{}.{}r   zinvalid.modulez.spamz	spam.eggs)r*   iter_importersget_importerr   r$   r   r%   r   r   r-   rJ   r   r   r   rM   	_get_specr   r   r?   	machinery
FileFinderr,   SourceFileLoaderassertIsNonerr   r   r   r   KeyError)r   r   r   r   modnamer   pathitemr   	importersexpected_importerfinderr   r   s                r   test_iter_importersz#ExtendPathTests.test_iter_importers  so    /+""7++7<<11>>'733$'''&&&"	!!'7GQ???#H---^^H5566I ,X 6 6# F F(::#]FF%    D %%fi.A.LMMM  ):;;;%%f&/&9&JL L L!!'"3FG"D"DEEEE"";// 7 7^^$4556667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 "";// . .^^G,,---. . . . . . . . . . . . . . . M'"""K'K,,,    M'"""K'K,,   s   )A/J D! J !
D.+J -D..B&J G9-J 9G==J  G=J I7J IJ 
IJ 0J 
JJ"K+ KK+
K(%K+'K((K+c           
      l   d}|                      |          }|                      |          }|                     ||dd           t          j        t          j                            ||d                     |                     ||dd           dd l}dd l}|                     |j	        j
        d           |                     |j        j
        d           |                     t          |j                  t          t          j                            ||          t          j                            ||          g                     t          j        |           t          j        |           t           j        d= t           j        d= t           j        d= t           j        d= t           j        d= d S )	Nry   r   r   r   r   r^   r   r   )r   r   r$   unlinkr   r%   r   r   r,   r   r   r   r   r   r   r   r   r-   r   s        r   test_mixed_namespacez$ExtendPathTests.test_mixed_namespace  s   $$W--	$$W--	i%;;;
	"',,y'=AABBBi%;;;****** 	--i!A!A!#i!A!A!C D D	E 	E 	E
 	i   i   HQKHQKKK	"K	"""r   N)r   r   r   r   r   r   r   r   r_   r   r   r   r   o  s`        	 	 	5 5 5
# # #:- - -`# # # # #r   r   c                   &    e Zd Zd Zd Zd Zd ZdS )NestedNamespacePackageTestc                 h    t          j                    | _        t          j        d d          | _        d S r   )r   r   basedirr   r   old_pathr   s    r   r   z NestedNamespacePackageTest.setUp  s'    '))r   c                 d    | j         t          j        d d <   t          j        | j                   d S r   )r   r   r   r   r   r   r   s    r   r   z#NestedNamespacePackageTest.tearDown  s+    mdl#####r   c                    |                     dd          \  }}t          j                            | j        |                    dt          j        j                            }t          j        |d           t          t          j                            ||dz             d          5 }|	                    |           d d d            d S # 1 swxY w Y   d S )N.r^   Tr~   r   r7   )
rsplitr$   r   r%   r   replacesepr   r'   r)   )r   rB   contentsbasefinal	base_pathr1   s          r   r   z(NestedNamespacePackageTest.create_module  s    kk#q))eGLLt||C/M/MNN	
I----"',,y%%-88#>> 	!GGH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   )CCCc                    d}|                      d|           |                      d|           |                      d|           |                      d|           |                      dd           |                      dd	           t          j                            d
t          j                            | j        d                     t          j                            d
t          j                            | j        d                     d
d l}|                     t          d           | 
                    t          |j                  d           d
d l}|                     t          d           | 
                    t          |j        j                  d           d
dlm} d
dlm} | 
                    |d           | 
                    |d           d S )NzBimport pkgutil; __path__ = pkgutil.extend_path(__path__, __name__)za.pkg.__init__zb.pkg.__init__za.pkg.subpkg.__init__zb.pkg.subpkg.__init__za.pkg.subpkg.czc = 1zb.pkg.subpkg.dzd = 2r   abr.      z
pkg.subpkg)c)rW   r^   )r   r   r   r   r$   r%   r   r.   r   r   r,   r   r   
pkg.subpkgsubpkgpkg.subpkg.cr  pkg.subpkg.drW   )r   pkgutil_boilerplater.   r  rW   s        r   test_nestedz&NestedNamespacePackageTest.test_nested  s   A 	 	+-@AAA+-@AAA24GHHH24GHHH+W555+W55527<<c::;;;27<<c::;;;


&&&S\**A...---SZ0111555""""""""""""AAr   N)r   r   r   r   r   r   r  r_   r   r   r   r     sP        $ $ $$ $ $      r   r   c                       e Zd Zd Zd Zd Zd Z ej        e dk    d          d             Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd ZdS )ImportlibMigrationTestsc                 .    t          dt          f          S )Nz[This emulation is deprecated and slated for removal in Python 3.12; use 'importlib' instead)r   DeprecationWarningr   s    r   check_deprecatedz(ImportlibMigrationTests.check_deprecated  s!    4!" " 	"r   c                     |                                  5  t          j        d           d d d            d S # 1 swxY w Y   d S Nr9   )r  r*   ImpImporterr   s    r   test_importer_deprecatedz0ImportlibMigrationTests.test_importer_deprecated   s    ""$$ 	$ 	$###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$s   7;;c                     |                                  5  t          j        dddd           d d d            d S # 1 swxY w Y   d S r  )r  r*   	ImpLoaderr   s    r   test_loader_deprecatedz.ImportlibMigrationTests.test_loader_deprecated$  s    ""$$ 	. 	.b"b"---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   :>>c                    t                      5 }|                     t          j        d                     |                     t          j        d                     |                     t          j        d                     |                     t          |j                  d           d d d            d S # 1 swxY w Y   d S Nr   r$   ztest.supportr   )r   assertIsNotNoner*   
get_loaderr,   r   warningsr   r7   s     r    test_get_loader_avoids_emulationz8ImportlibMigrationTests.test_get_loader_avoids_emulation(  s     	1  !3E!:!:;;;  !3D!9!9:::  !3N!C!CDDDS__a000		1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1   BB::B>B>__main__znot compatible with __main__c                    t           }b 	 t                      5 }|                     t          j        t
                               |                     t          |j                  d           d d d            n# 1 swxY w Y   |a d S # |a w xY wr   )	
__loader__r   r  r*   r  r   r,   r   r  )r   this_loaderr7   s      r   0test_get_loader_handles_missing_loader_attributezHImportlibMigrationTests.test_get_loader_handles_missing_loader_attribute/  s     !	%!! 5Q$$W%7%A%ABBB  QZ!4445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 %JJJJ$$$$s/   B AA9-B 9A==B  A=B Bc                    d} t          t                    |          }|`t          |          5  |t          j        |<   t          j        |          }d d d            n# 1 swxY w Y   |                     |           d S Nr   typer   __spec__r   r-   r*   r  r   r   rB   rd   r   s       r   .test_get_loader_handles_missing_spec_attributezFImportlibMigrationTests.test_get_loader_handles_missing_spec_attribute;  s    d3iiooL 	. 	. #CK'--F	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	&!!!!!s   $A!!A%(A%c                    d} t          t                    |          }d |_        t          |          5  |t          j        |<   t          j        |          }d d d            n# 1 swxY w Y   |                     |           d S r&  r'  r*  s       r   +test_get_loader_handles_spec_attribute_nonezCImportlibMigrationTests.test_get_loader_handles_spec_attribute_noneD  s    d3iioo 	. 	. #CK'--F	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	&!!!!!s   $A&&A*-A*c                     d}d t           j        |<   	 t          j        |          }t           j        |= n# t           j        |= w xY w|                     |           d S Nztotally bogus)r   r-   r*   r  r   r   rB   r   s      r   #test_get_loader_None_in_sys_modulesz;ImportlibMigrationTests.test_get_loader_None_in_sys_modulesM  se     D	"'--FD!!D!!!!!&!!!!!s	   5 Ac                 \    d}t          j        |          }|                     |           d S r/  )r*   find_loaderr   r0  s      r   test_find_loader_missing_modulez7ImportlibMigrationTests.test_find_loader_missing_moduleV  s1    $T**&!!!!!r   c                    t                      5 }|                     t          j        d                     |                     t          j        d                     |                     t          j        d                     |                     t          |j                  d           d d d            d S # 1 swxY w Y   d S r  )r   r  r*   r3  r,   r   r  r  s     r   !test_find_loader_avoids_emulationz9ImportlibMigrationTests.test_find_loader_avoids_emulation[  s     	1  !4U!;!;<<<  !4T!:!:;;;  !4^!D!DEEES__a000		1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1r  c                     t                      5 }|                     t          j        d                     |                     t          |j                  d           d d d            d S # 1 swxY w Y   d S )Nz*??r   )r   r   r*   r   r,   r   r  r  s     r   "test_get_importer_avoids_emulationz:ImportlibMigrationTests.test_get_importer_avoids_emulationb  s     	1g2599:::S__a000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   AA,,A03A0c                     	 t          j        t          d                     d S # t          $ r |                     d           Y d S w xY w)Nz/homez3Unexpected AttributeError when calling get_importer)r*   r   r   r   rU   r   s    r   test_issue44061z'ImportlibMigrationTests.test_issue44061h  s`    	M g///// 	M 	M 	MIIKLLLLLL	Ms   !% AAc                     t                      5 }t          j                    D ]}|                     t	          |j                  d           d d d            d S # 1 swxY w Y   d S r   )r   r*   r   r,   r   r  )r   r7   importers      r   $test_iter_importers_avoids_emulationz<ImportlibMigrationTests.test_iter_importers_avoids_emulationn  s     	1#244::S__a000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   ?AA"AN)r   r   r   r  r  r  r  unittestskipIfr$  r+  r-  r1  r4  r6  r8  r:  r=  r_   r   r   r  r    s        
" " "$ $ $. . .1 1 1 X_X+-KLL	% 	% ML	%" " "" " "" " "" " "
1 1 11 1 1M M M1 1 1 1 1r   r  c                  f    dd l } dd l}| j                                          |j                     d S r   )	zipimportr   _zip_directory_cacheclearr   )rA  r   s     r   tearDownModulerD  t  sF    "((***I!!!!!r   r   )pathlibr   test.support.import_helperr   r   test.support.warnings_helperr   r>  r   r   importlib.utilr   r*   r$   os.pathr   r   r;   TestCaser	   r   r   r   r  rD  r   mainr_   r   r   <module>rL     s         : : : : : : : : 7 7 7 7 7 7  



     2 2 2 2 2 2  				    j, j, j, j, j,8$ j, j, j,Z	( ( ( ( (* ( ( (Zx# x# x# x# x#h' x# x# x#z& & & & &!2 & & &R\1 \1 \1 \1 \1h/ \1 \1 \1~" " " zHMOOOOO r   