
    daf                         d dl mZ d dlZd dlZd dlmZ d dlmZ  G d d      Z ej                  eej                        \  ZZedk(  r ej                          yy)	    )utilN)support)import_helperc                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
ParentModuleTestsz7Importing a submodule should import the parent modules.c                    t        j                  dd      5 }t        j                  |g      5  | j                  d      }| j	                  dt
        j                         d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Npkg.__init__
pkg.module	meta_pathpkg)r   	mock_specimport_state
__import__assertInsysmodules)selfmockmodules      D/root/Python-3.12.4/Lib/test/test_importlib/import_/test_packages.pytest_import_parentz$ParentModuleTests.test_import_parent   sq    ^^NL9 	2T""dV4 26eS[[12	2 	22 2	2 	2s"   A>2A2!A>2A;	7A>>Bc                 r   t        j                  d      5 }t        j                  |g      5  | j                  t              5 }| j                  d       d d d        | j                  j                  j                  d       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)Nr
   r   r   )	r   r   r   assertRaisesImportErrorr   assertEqual	exceptionname)r   r   cms      r   test_bad_parentz!ParentModuleTests.test_bad_parent   s    ^^L) 	;T""dV4 ;&&{3 2rOOL12  !2!2E:;	; 	;2 2; ;	; 	;s:   B-B!B.B!B-BB!!B*	&B--B6c                    d }t        j                  ddd|i      }|5  t        j                  |g      5  | j                  t              5  | j                  d       d d d        | j                  dt        j                         | j                  dt        j                         | j                  t              5  | j                  d       d d d        | j                  dt        j                         | j                  dt        j                         d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   fxY w# 1 sw Y   *xY w# 1 sw Y   y xY w)Nc                      dd l } ddz   y )Nr      )
pkg.module)r   s    r   __init__zMParentModuleTests.test_raising_parent_after_importing_child.<locals>.__init__   s    aC    r	   r
   r   module_coder   )
r   r   r   r   ZeroDivisionErrorr   assertNotInr   r   r   r   r%   r   s      r   )test_raising_parent_after_importing_childz;ParentModuleTests.test_raising_parent_after_importing_child   s   	 ~~nl.3X->@ 		9""dV4 9&&'89 +OOE*+  4lCKK8&&'89 2OOL12  4lCKK89		9 		9+ +2 29 9		9 		9sT   EE D( AE =D4AE E(D1-E 4D=9E  E		EEc                 H   d }t        j                  ddd|i      }|5  t        j                  |g      5  | j                  t        t
        f      5  | j                  d       d d d        | j                  dt        j                         | j                  t        t
        f      5  | j                  d       d d d        | j                  dt        j                         d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   FxY w# 1 sw Y   *xY w# 1 sw Y   y xY w)Nc                      ddl m}  ddz   y )Nr#   r   r   ) r   r/   s    r   r%   zVParentModuleTests.test_raising_parent_after_relative_importing_child.<locals>.__init__+   s     aCr&   r	   r
   r   r'   r   
r   r   r   r   r)   r   r   r*   r   r   r+   s      r   2test_raising_parent_after_relative_importing_childzDParentModuleTests.test_raising_parent_after_relative_importing_child*   s    	 ~~nl.3X->@ 		5""dV4 5&&(9;'GH + OOE*+   4&&(9;'GH 2OOL12  45		5 		5+ +
2 25 5		5 		5sS   DDC4&AD)D ;(D#D4C=9D D	DD	DD!c                 J   d }t        j                  dddd|i      }|5  t        j                  |g      5  | j                  t        t
        f      5  | j                  d       d d d        | j                  dt        j                         | j                  t        t
        f      5  | j                  d       d d d        | j                  dt        j                         d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   FxY w# 1 sw Y   *xY w# 1 sw Y   y xY w)Nc                      ddl m}  ddz   y )N   r/   r#   r   )subpkgr   r/   s    r   r%   z]ParentModuleTests.test_raising_parent_after_double_relative_importing_child.<locals>.__init__>   s    'aCr&   r	   zpkg.subpkg.__init__zpkg.subpkg.modulez
pkg.subpkgr'   r   r1   r+   s      r   9test_raising_parent_after_double_relative_importing_childzKParentModuleTests.test_raising_parent_after_double_relative_importing_child=   s   	 ~~n.C!4.:H-EG  		<""dV4 <&&(9;'GH 2 OOL12   s{{;&&(9;'GH 9OO$789  s{{;<		< 		<2 2
9 9< <		< 		<sS   DDC5'AD*D<(D$D5C>:DD
DD	DD"c                     t        t        d      rJ | j                  t              5 }| j	                  d       d d d        | j                  j                  j                  d       y # 1 sw Y   0xY w)N__path__zsys.no_submodules_here)hasattrr   r   r   r   r   r   r   )r   r   s     r   test_module_not_packagez)ParentModuleTests.test_module_not_packageQ   s_    3
+++{+ 	6rOO45	6**,DE	6 	6s   A))A2c                 Z   d}|dz   fd}t        j                  dd|i      }|5 }t        j                  |g      5  	 | j                        }t	        j
                         	 d d d        d d d        y # t	        j
                         w xY w# 1 sw Y   ,xY w# 1 sw Y   y xY w)Nmodz.bc                  ,    dt         j                   <   y )Nz
total bunk)r   r   )subnames   r   module_injectionzTParentModuleTests.test_module_not_package_but_side_effects.<locals>.module_injection]   s    #/CKK r&   r'   r   )r   r   r   r   r   unload)r   r   r@   r   r   	submoduler?   s         @r   (test_module_not_package_but_side_effectsz:ParentModuleTests.test_module_not_package_but_side_effectsX   s     +	0NN56;=M5NP	 	2$""dV4 22 $ 8I!((1	2	2 	2
 "((1	2 2	2 	2s;   B!BA;B*B!;BBB	B!!B*N)__name__
__module____qualname____doc__r   r    r,   r2   r7   r;   rC    r&   r   r   r      s)    A2;9"5&<(F2r&   r   )r   __main__)test.test_importlibr   r   unittesttestr   test.supportr   r   	test_bothr   Frozen_ParentTestsSource_ParentTestsrD   mainrH   r&   r   <module>rR      s]    $ 
   &^2 ^2F T^^%$//B zHMMO r&   