
    7bh                         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  G d dej                        Z	e
dk(  r ej                          yy)    N)script_helperc                   x    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 Zd Zd Zd Zd Zd Zd Zd Zy)StructSeqTestc                 p   t        j                         }| j                  |t               t        |      }| j	                  t        |      t        |             | j	                  ||       t        t        |       t        |            D ]V  }| j	                  ||d  ||d         t        t        |       t        |            D ]  }| j	                  ||| |||         X t        t        |       t        |            D ]  }| j	                  |d | |d |         | j                  t        |j                  t        |       dz
         | j                  t        |j                  t        |             t        t        |       t        |      dz
        D ]  }| j	                  ||   ||           y N   )
timegmtimeassertIsInstancetupleassertEquallenrangeassertRaises
IndexError__getitem__)selftastupleijs        =/opt/python-3.12.12/usr/lib/python3.12/test/test_structseq.py
test_tuplezStructSeqTest.test_tuple   sj   KKMa'(QW.G$ AwA'AQqrUGABK0CF7CF+  1Q16 , (
 AwA'AQrUGBQK0 ( 	*ammc!fWQY?*ammSV<AwAq)AQqT71:. *    c                    t        j                         }| j                  t        |             t        j                  d      }| j	                  t        |      d       t        j                  t              }t        |      }| j                  |j                  d             | j                  d|       | j                  d|       | j                  d|       y )Nr   zttime.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)zos.stat_resultzst_mode=zst_ino=zst_dev=)
r	   r
   
assertTruereprr   osstat__file__
startswithassertIn)r   r   streps       r   	test_reprzStructSeqTest.test_repr"   s    KKMQ KKNaD	E WWX2h'789j#&i%i%r   c           	          t        j                         }|t        |      z   }t        t	        |            D ]&  }| j                  ||   ||t	        |      z             ( y N)r	   r
   r   r   r   r   r   t1t2r   s       r   test_concatzStructSeqTest.test_concat1   sL    [[]%)^s2wARUBqRyM2  r   c           
          t        j                         }d|z  }t        t        |            D ]M  }| j	                  ||   ||t        |      z             | j	                  ||   ||dt        |      z  z             O y )N      )r	   r
   r   r   r   r(   s       r   test_repeatzStructSeqTest.test_repeat7   sl    [[]Vs2wARUBqRyM2RUBq3r7{O4  r   c                     t        j                         }|D ]  }| j                  ||        | j                  d|       y )Ni)r	   r
   r"   assertNotIn)r   r)   items      r   test_containszStructSeqTest.test_contains>   s5    [[]DMM$# b!r   c                     t        j                         }| j                  t        |      t        t	        |                   y r'   )r	   r
   r   hashr   )r   r)   s     r   	test_hashzStructSeqTest.test_hashD   s)    [[]b4b	?3r   c                 @   t        j                         } t        |      |      }| j                  ||       | j	                  ||k          | j	                  ||k         | j	                  ||kD          | j	                  ||k\         | j	                  ||k7          y r'   )r	   r
   typer   r   )r   r)   r*   s      r   test_cmpzStructSeqTest.test_cmpH   s    [[]T"Xb\R R"W&b!R"W&b!R2X'r   c                    t        j                         }| j                  t        |      |j                         | j                  |j
                  d       | j                  |j                  t         j                         y Nr   )r	   r
   r   r   n_sequence_fieldsn_unnamed_fieldsn_fields_STRUCT_TM_ITEMS)r   r   s     r   test_fieldszStructSeqTest.test_fieldsR   sW    KKMQ!4!45++Q/T%:%:;r   c                 b   t         j                  }| j                  t        |       | j                  t        |d        | j                  t        |d       | j                  t        |di        | j                  t        |dd        d}| j	                  dj                   ||            |       y )N123)dict	123456789 )r	   struct_timer   	TypeErrorr   join)r   r   ss      r   test_constructorzStructSeqTest.test_constructorX   s    )Q')Q-)Q.)QB7)Q$?1*r   c                      G d dt                G fdd      }| j                  t        j                   |              y )Nc                       e Zd Zy))StructSeqTest.test_eviltuple.<locals>.ExcN)__name__
__module____qualname__ r   r   ExcrM   e   s    r   rR   c                       e Zd Z fdZd Zy)'StructSeqTest.test_eviltuple.<locals>.Cc                     r'   rQ   )r   r   rR   s     r   r   z3StructSeqTest.test_eviltuple.<locals>.C.__getitem__j   s    	r   c                      y)N	   rQ   r   s    r   __len__z/StructSeqTest.test_eviltuple.<locals>.C.__len__l   s    r   N)rN   rO   rP   r   rY   )rR   s   r   CrT   i   s    r   rZ   )	Exceptionr   r	   rF   )r   rZ   rR   s     @r   test_eviltuplezStructSeqTest.test_eviltupled   s5    	) 		 	 	#t//5r   c                    t        j                         }t        t        j                  dz         D ]  }t        j
                  ||      }t        j                  |      }| j                  |j                  |j                         | j                  ||       | j                  |j                  |j                         | j                  |j                  |j                          y r   )r	   r
   r   pickleHIGHEST_PROTOCOLdumpsloadsr   	__class__tm_yeartm_zone)r   r   protopr*   s        r   test_picklingzStructSeqTest.test_picklingq   s    KKM622Q67EQ&AaBR\\1;;7R#RZZ3RZZ3 8r   c                 d   t        j                  t        t         j                  j                        ddd      }t        t        j
                  dz         D ]  }t	        j                  ||      }t	        j                  |      }| j                  |j                  |j                         | j                  ||       | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                          y )N      ?       @st_atimest_atime_nsr   )r   stat_resultr   r<   r^   r_   r`   ra   r   rb   st_moderl   rm   )r   rre   rf   r2s        r   !test_pickling_with_unnamed_fieldsz/StructSeqTest.test_pickling_with_unnamed_fields{   s     NN5!A!AB(+C@B622Q67EQ&AaBR\\1;;7R#RZZ3R[[!**5R^^Q]]; 8r   c                    t         j                  j                  }t        j                  t        |      D cg c]  }|g c}      }t	        j                  |      }| j                  |j                  |j                         | j                  ||       | j                  |j                  |j                         | j                  |j                  |j                         | j                  |d   |d          | j                  |j                  |j                         t	        j                  |      }| j                  |j                  |j                         | j                  ||       | j                  |j                  |j                         | j                  |j                  |j                         | j                  |d   |d          | j                  |j                  |j                         y c c}w r;   )r	   rF   r>   r   copyr   rb   rc   rd   assertIsdeepcopyassertIsNot)r   r>   r   r   r*   t3s         r   test_copyingzStructSeqTest.test_copying   sd   ##,,5?;?aqc?;<YYq\q{{3QQYY/QYY/beQqT"bjj!)),]]1q{{3QQYY/QYY/A!%QYY/! <s   
G7c                    t         j                  j                  }t        j                  t        |      D cg c]  }|g c}dgdgd      }t	        j                  |      }| j                  |j                  |j                         | j                  ||       | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |d   |d          | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         t	        j                  |      }| j                  |j                  |j                         | j                  ||       | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |d   |d          | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         y c c}w )Nri   rj   rk   r   )r   rn   r<   r   rt   r   rb   ro   rl   rm   ru   rv   rw   )r   r<   r   rp   rq   r3s         r    test_copying_with_unnamed_fieldsz.StructSeqTest.test_copying_with_unnamed_fields   s    NN<<NN/@)AB)AAQC)AB),seDF YYq\q{{3QQYY/ajj17beQqT"bjj!)),bkk1::.bnnamm4]]1q{{3QQYY/ajj17A!%QYY/ajj17/ Cs   
K!c                     t        j                         }t        |      }d}|D ]:  }|D ]3  }|dd  D ])  }| j                  t        ||||         ||||          + 5 < y )N)
r   Nr   r-      i,  iir   )r	   r
   listr   )r   r   Lindicesstartstopsteps          r   test_extended_getslicez$StructSeqTest.test_extended_getslice   sm    KKMG=E#ABKD$$T!E$tO*<%=%&uT$%79 (   r   c                 \    d}| j                  t        j                  j                  |       y )N)	rc   tm_montm_mdaytm_hourtm_mintm_sectm_wdaytm_ydaytm_isdst)r   r	   rF   __match_args__r   expected_argss     r   test_match_argszStructSeqTest.test_match_args   s&    E))88-Hr   c                     d}| j                  t        j                  j                  d       | j                  t        j                  j                  |       y )N)ro   st_inost_devst_nlinkst_uidst_gidst_sizer-   )r   r   rn   r=   r   r   s     r   #test_match_args_with_unnamed_fieldsz1StructSeqTest.test_match_args_with_unnamed_fields   s=    .88!<66Fr   c                 V    t        j                  dt        j                  d             y )Nz-cz_
            import time
            t = time.gmtime()
            type(t).refcyle = t
        )r   assert_python_oktextwrapdedentrX   s    r   test_reference_cyclez"StructSeqTest.test_reference_cycle   s$    
 	&&tX__ > . 	r   N)rN   rO   rP   r   r%   r+   r/   r3   r6   r9   r@   rJ   r\   rg   rr   ry   r|   r   r   r   r   rQ   r   r   r   r   
   s^    /,&35"4(<
+64<0(8:
9I
G	r   r   __main__)rt   r   r^   r   r	   unittesttest.supportr   TestCaser   rN   mainrQ   r   r   <module>r      sI     	     &PH%% Pf zHMMO r   