+
    Bi                     B   ^ RI t ^ RI Ht ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
Ht  ! R R4      t ! R R]P                  4      t ! R	 R
]P                  ]P                   4      t ! R R]P                  4      t]R8X  d   ]P(                  ! 4        R# R# )    N)abc)util)threading_helperc                   ,   a  ] tR t^t o R tR tRtV tR# )CollectInitc                    Wn         W n        R # Nargskwargs)selfr   r   s   &*,4/usr/lib/python3.14/test/test_importlib/test_lazy.py__init__CollectInit.__init__   s    	    c                    V # r	    r   modules   &&r   exec_moduleCollectInit.exec_module   s    r   r
   N)__name__
__module____qualname____firstlineno__r   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s      r   r   c                   ,   a  ] tR t^t o R tR tRtV tR# )LazyLoaderFactoryTestsc                    \         P                  P                  \        4      pV! R RRR7      pVP                  pV P                  RVP                  4       V P                  RR/VP                  4       R# )module namemodule pathkw)r%   N)r#   r$   )r   
LazyLoaderfactoryr   loaderassertEqualr   r   )r   r'   lazy_loaderr(   s   &   r   	test_init LazyLoaderFactoryTests.test_init   s^    //))+6 m]tD##7E$v}}5r   c                    V P                  \        4      ;_uu_ 4        \        P                  P	                  \
        4       R R R 4       R #   + '       g   i     R # ; ir	   )assertRaises	TypeErrorr   r&   r'   objectr   s   &r   test_validation&LazyLoaderFactoryTests.test_validation#   s4    y))OO##F+ *)))s   $AA	r   N)r   r   r   r   r+   r2   r   r   r   s   @r   r!   r!      s     6, ,r   r!   c                   b   a  ] tR t^)t o RtRtRt^ tRP                  ]4      t	RR lt
R tRtV tR# )	TestingImporterlazy_loader_testchangedNzattr = 42; __name__ = {!r}c                |    WP                   8w  d   R # \        P                  ! V\        P                  ! V 4      4      # r	   )module_namer   spec_from_loaderr&   )r   namepathtargets   &&&&r   	find_specTestingImporter.find_spec1   s-    ###$$T4??4+@AAr   c                    \         P                  ! R 4       \        V P                  VP                  4       Wn        V ;P                  ^,          un        R# )g{Gz?N)timesleepexecsource_code__dict__loaded
load_countr   s   &&r   r   TestingImporter.exec_module6   s5    

4Tv/1r   )rF   r	   )r   r   r   r   r9   mutated_namerF   rG   formatrD   r>   r   r   r   r   s   @r   r5   r5   )   s9     $KLFJ.55lCKB
 r   r5   c                      a  ] tR t^=t o R tRR ltR tR tR tR t	R t
R	 tR
 tR tR t]P                   ! 4       R 4       tR tR tRtV tR# )LazyLoaderTestsc                    V P                  \        4      ;_uu_ 4        \        P                  ! \        4       R R R 4       R #   + '       g   i     R # ; ir	   )r.   r/   r   r&   r0   r1   s   &r   r+   LazyLoaderTests.test_init?   s.    y))OOF# *)))s   AA	Nc                   Vf   \        4       pVe   Wn        \        P                  ! \         P                  \        P
                  ! V4      4      pVP                  P                  V4      pVf%   \        P                  ! \         P                  4      pW4n
        VP                  Vn        VP                  P                  V4       V P                  VP                  4       V# r	   )r5   rD   r   r:   r9   r&   r(   create_moduletypes
ModuleType__spec__
__loader__r   assertIsNonerF   )r   rD   r(   specr   s   &&&  r   
new_moduleLazyLoaderTests.new_moduleD   s    >$&F"!,$$_%@%@%)__V%<>**40>%%o&A&ABF KK'&--(r   c           	     T   \        4       pVP                  e   Q h\        P                  ! VP                  4      ;_uu_ 4        \        P
                  ! V.R7      ;_uu_ 4        \        P                  ! VP                  4      pR R R 4       R R R 4       V P                  VP                  4       V P                  XP                  V4       V P                  VP                  4       V P                  W!P                  4       R #   + '       g   i     L; i  + '       g   i     L; i)N)	meta_path)r5   rF   	test_utiluncacher9   import_state	importlibimport_modulerU   r)   rT   assertIsNotNone)r   importerr   s   &  r   test_e2eLazyLoaderTests.test_e2eU   s    "$&&&x3344''8*=="001E1EF > 5 	(//***H5X__-1 >= 54s$   !D$!D	DDDD'	c                z    V P                  4       pV P                  \        P                  VP                  4       R # r	   )rW   r)   r5   rI   r   r   s   & r   test_attr_unchanged#LazyLoaderTests.test_attr_unchangedb   s*     "55vGr   c                l    V P                  4       p^*Vn        V P                  ^*VP                  4       R# )*   N)rW   new_attrr)   r   s   & r   test_new_attrLazyLoaderTests.test_new_attrh   s)    "V__-r   c                l    V P                  4       pR Vn        V P                  R VP                  4       R# )bogusN)rW   r   r)   r   s   & r   test_mutated_preexisting_attr-LazyLoaderTests.test_mutated_preexisting_attrn   s+     "!&//2r   c                l    V P                  4       p^Vn        V P                  ^VP                  4       R# )   N)rW   attrr)   r   s   & r   test_mutated_attr!LazyLoaderTests.test_mutated_attru   s+     "FKK(r   c                N    V P                  4       pV=V P                  VR 4       R# )rr   N)rW   rr   assertNotHasAttrr   s   & r   test_delete_eventual_attr)LazyLoaderTests.test_delete_eventual_attr|   s#    "Kff-r   c                N    V P                  4       pV=V P                  VR 4       R# )r   N)rW   r   rv   r   s   & r   test_delete_preexisting_attr,LazyLoaderTests.test_delete_preexisting_attr   s#    "Ofj1r   c           	        \         P                  ! \        P                  4      ;_uu_ 4        \        P
                  ! \        P                  4      pV\        P                  \        P                  &   V P                  4       pV P                  \        R 4      ;_uu_ 4        VP                   RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)substitutedN)r[   r\   r5   r9   rQ   rR   sysmodulesrW   assertRaisesRegex
ValueErrorr   )r   fresh_moduler   s   &  r   test_module_substitution_error.LazyLoaderTests.test_module_substitution_error   s    ::;; ++O,G,GHL7CCKK334__&F''
MBB C	 <; CB	 <;;s$   A4C!C 	.C CCC$	c                   \         P                  ! \        P                  4      ;_uu_ 4        V P	                  4       pV\
        P                  \        P                  &   VP                   R R R 4       R #   + '       g   i     R # ; ir	   )r[   r\   r5   r9   rW   r~   r   r   r   s   & r   test_module_already_in_sys*LazyLoaderTests.test_module_already_in_sys   sO    ::;;__&F7=CKK334OO	 <;;;s   >A55B	c           	     d  a \         P                  ! \        P                  4      ;_uu_ 4        \        4       pV P	                  VR 7      oV P                  VP                  ^ 4        ! R R\        P                  4      pV3R lp. p\        ^4       F-  pVP                  V! VR7      ;p4       VP                  4        K/  	  V F.  pVP                  4        V P                  VP                  4       K0  	  V P                  VP                  ^4       RRR4       R#   + '       g   i     R# ; i))r(   c                   6   a a ] tR t^t oRtV 3R ltRtVtV ;t# )<LazyLoaderTests.test_module_load_race.<locals>.RaisingThreadNc                d   <  \         SV `  4        R #   \         d   pYn         R p?R # R p?ii ; ir	   )superrun	Exceptionexc)r   r   	__class__s   & r   r   @LazyLoaderTests.test_module_load_race.<locals>.RaisingThread.run   s(    '$ '#&'s    /*/)r   )	r   r   r   r   r   r   r   r   __classcell__)r   r   s   @@r   RaisingThreadr      s     ' 'r   r   c                     < S P                   # r	   )rr   )r   s   r   access_module<LazyLoaderTests.test_module_load_race.<locals>.access_module   s    {{"r   )r=   N)r[   r\   r5   r9   rW   r)   rG   	threadingThreadrangeappendstartjoinrU   r   )r   r(   r   r   threads_threadr   s   &      @r   test_module_load_race%LazyLoaderTests.test_module_load_race   s    ::;;$&F__F_3FV..2'	 0 0 '# G1Xm)LLvM 
 "!!&**- "
 V..27 <;;;s   C&DD/	c                "   \         P                   Uu. uF  qP                  R 4      '       g   K  VNK  	  pp\        P                  ! V!  ;_uu_ 4        \
        P                  ! R 4      p\
        P                  ! VP                  4      pWCn        \
        P                  ! V4      pV\         P                  R &   VP                  V4       VP                  R4      pV P                  V/ 4       RRR4       R# u upi   + '       g   i     R# ; i)jsonz{}N)r~   r   
startswithr[   r\   r   r>   r&   r(   module_from_specr   loadsr)   )r   r;   json_modulesrV   r(   r   	test_loads   &      r   "test_lazy_self_referential_modules2LazyLoaderTests.test_lazy_self_referential_modules   s     *-P8OP-->>&)D__T[[1F K**40F"(CKKv& T*IY+ .- Q---s   C8C8BC==D	c                   V P                  R R7      pV\        P                  \        P                  &   V P                  V\        P                  4       V P                  VP                  R4       V P                  \        4      ;_uu_ 4        RVn	        RRR4       V P                  \        4      ;_uu_ 4        V=	RRR4       R#   + '       g   i     L:; i  + '       g   i     R# ; i)aD  import sys
from types import ModuleType

CONSTANT = 3.14

class ImmutableModule(ModuleType):
    def __setattr__(self, name, value):
        raise AttributeError('Read-only attribute!')

    def __delattr__(self, name):
        raise AttributeError('Read-only attribute!')

sys.modules[__name__].__class__ = ImmutableModule
)rD   gQ	@gGz@N)rW   r~   r   r5   r9   assertIsInstancer   _LazyModuler)   CONSTANTr.   AttributeErrorr   s   & r   test_lazy_module_type_override.LazyLoaderTests.test_lazy_module_type_override   s    
  .  4:O//0fd&6&67$/~.."FO /~.. /. /....s   C:CC	C+	r   )NN)r   r   r   r   r+   rW   rb   re   rj   rn   rs   rw   rz   r   r   r   requires_working_threadingr   r   r   r   r   r   s   @r   rL   rL   =   si     $
"2H.3).2
  0023 33<,$   r   rL   __main__)r^   r   r   r~   rA   r   rQ   unittesttest.supportr   test.test_importlibr[   r   TestCaser!   MetaPathFinderLoaderr5   rL   r   mainr   r   r   <module>r      s       
     ) 1 ,X.. ,"c((#** (d h'' d N zMMO r   