
    <e\                        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
Z
d dlZd dlZd dlZd dlZ	 d dlZn# e$ r dZY nw xY w G d d          Z G d dej        e          Z G d	 d
ej        e          Z G d dej        e          Z G d dej                  Z G d dej                  Z G d dej        e          Z G d dej        e          Z G d dej                  ZdZe
j        dk    rdndZ G d d          Z ej        ee
j        k    d           G d dej                              Z d  Z! G d! d"ej        e          Z" G d# d$ej                  Z# G d% d&ej        e          Z$ej%         ej&        ed'           G d( d)ej        e                                  Z'e(d*k    r ej)                     dS dS )+    )support)	os_helperrequires_debug_ranges)assert_python_okNc                       e Zd Zd ZdS )HelperMixinc                 @   t          j        t          j        |g|R            }|                     ||           	 t	          t
          j        d          5 }t          j        ||g|R   d d d            n# 1 swxY w Y   t	          t
          j        d          5 }t          j        |          }d d d            n# 1 swxY w Y   |                     ||           t          j	        t
          j                   d S # t          j	        t
          j                   w xY w)Nwbrb)
marshalloadsdumpsassertEqualopenr   TESTFNdumploadunlink)selfsampleextranewfs        (/usr/lib/python3.11/test/test_marshal.pyhelperzHelperMixin.helper   sy   mGM&95999::%%%	/i&-- 0VQ/////0 0 0 0 0 0 0 0 0 0 0 0 0 0 0i&-- &l1oo& & & & & & & & & & & & & & &VS)))Y-.....IY-....sS   C= A6*C= 6A::C= =A:>C= B<0C= <C  C= C C= = DN)__name__
__module____qualname__r        r   r   r      s#        
/ 
/ 
/ 
/ 
/r    r   c                        e Zd Zd Zd Zd ZdS )IntTestCasec                 t    t           j        dz  }|r&| |fD ]}|                     |           |dz	  }|$d S d S )N      )sysmaxsizer   )r   nexpecteds      r   	test_intszIntTestCase.test_ints    sg    K1 	RG & &H%%%%QA  	 	 	 	 	r    c                 <   d}| dz
  }||| |dz	   fD ]_}|r[dt                               |ddd          z   }t          j        |          }|                     ||           |dk    rd	}n|dz  }|[`t          j        d
          }|                     |d           t          j        d          }|                     |d           t          j        d          }|                     |d           t          j        d          }|                     |d           d S )Nl    r%      I   littleT)signedr   s	   IܺvT2l   \u1Q s	   I#Egl\u1Q s	   I*;L]nl   Tv0ur{ s	   Iĳl	Tv0ur{ )intto_bytesr   r   r   )r   maxint64minint64basesgots         r   
test_int64zIntTestCase.test_int64(   sF    9Q;h	X]3CC 	 	D 3<<a$<GGGmA&&  s+++2::DDQJD   m@AA0111m@AA1222m@AA0111m@AA122222r    c                 :    dD ]}|                      |           d S )N)TFr   )r   bs     r   	test_boolzIntTestCase.test_bool?   s,     	 	AKKNNNN	 	r    N)r   r   r   r*   r8   r<   r   r    r   r"   r"      sA          3 3 3.    r    r"   c                       e Zd Zd ZdS )FloatTestCasec                 f   d}t           j        dz  }||k    r5| |fD ]$}|                     t          |                     %|dz  }||k    5d}t	          j        |d          }t	          j        |          }|                     ||           t	          j        |d          }t	          j        |          }|                     ||           t           j        dz  }||k     rO| |fD ]<}t          |          }|                     |           |                     |d           =|dz  }||k     Md S d S )Ng}:g6ҫsgS:^@g        r$   r%   gZ1%)r&   r'   r   floatr   r   r   r   )r   smallr(   r)   r   r6   r7   s          r   test_floatszFloatTestCase.test_floatsD   sJ   K'!%iiRG - -E(OO,,,,MA %ii
 M!QmAC   M!QmAC   K("%iiRG " "(OOAAq!!!!MA %iiiiiir    N)r   r   r   rB   r   r    r   r>   r>   C   s#            r    r>   c                        e Zd Zd Zd Zd ZdS )StringTestCasec                     dddddz  fD ];}|                      t          j        t          j        |                               <d S N    Andrè Previnabc '  )r   r   r   r   r   r6   s     r   test_unicodezStringTestCase.test_unicode_   sR    'E	: 	9 	9AKKgmA&6&6778888	9 	9r    c                 H    dddddz  fD ]}|                      |           d S rF   r:   rL   s     r   test_stringzStringTestCase.test_stringc   s:    'E	: 	 	AKKNNNN	 	r    c                 H    dddddz  fD ]}|                      |           d S )Nr    s   Andr Previn   abc    rK   r:   rL   s     r   
test_byteszStringTestCase.test_bytesg   s:    )64:> 	 	AKKNNNN	 	r    N)r   r   r   rM   rO   rS   r   r    r   rD   rD   ^   sA        9 9 9      r    rD   c                       e Zd Zd ZdS )ExceptionTestCasec                     t          j        t          j        t                              }|                     t          |           d S N)r   r   r   StopIterationr   )r   r   s     r   test_exceptionsz!ExceptionTestCase.test_exceptionsl   s7    mGM-8899,,,,,r    N)r   r   r   rY   r   r    r   rU   rU   k   s#        - - - - -r    rU   c                   f    e Zd Zd Zd Zd Z e            d             Zej	        d             Z
dS )CodeTestCasec                     t           j        j        }t          j        t          j        |                    }|                     ||           d S rW   )rU   rY   __code__r   r   r   r   )r   cor   s      r   	test_codezCodeTestCase.test_codeq   sB    .7mGM"--..S!!!!!r    c                     d}t           j        j        f|z  }t          j        t          j        |                     d S )Ni  )rU   rY   r]   r   r   r   )r   countcodess      r   test_many_codeobjectsz"CodeTestCase.test_many_codeobjectsv   s:    "2;=EgmE**+++++r    c                    t          ddd          }t          ddd          }t          j        t          j        ||f                    \  }}|                     |j        d           |                     |j        d           d S )Nxf1execyf2)compiler   r   r   r   co_filename)r   co1co2s      r   test_different_filenamesz%CodeTestCase.test_different_filenames|   s{    c4((c4((=Sz!:!:;;S$///$/////r    c                    t           j        j        }t          j        d          }	 t          t          j        d          5 }t          j	        ||           d d d            n# 1 swxY w Y   t          ddd|t          j                   t          j        t          j                   d S # t          j        t          j                   w xY w)Na  
        import sys
        import marshal
        with open(sys.argv[1], 'rb') as f:
            co = marshal.load(f)
            positions = list(co.co_positions())
            assert positions[0][2] is None
            assert positions[0][3] is None
        r
   z-Xno_debug_ranges-c)rU   rY   r]   textwrapdedentr   r   r   r   r   r   r   )r   r^   coder   s       r   +test_minimal_linetable_with_no_debug_rangesz8CodeTestCase.test_minimal_linetable_with_no_debug_ranges   s     .7    	/i&-- $R###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ T#4!4)9; ; ; Y-.....IY-....s/   B+ A#B+ #A''B+ *A'+ B+ + Cc                     d}t          |dd          }t          j        t          j        |                    }|j        D ]<}t          |t          j                  r |                     |j	        |j	                   =d S )Nzdef f(): pass
def g(): passmyfilerg   )
rj   r   r   r   	co_consts
isinstancetypesCodeTypeassertIsrk   )r   r6   r^   objs       r   test_same_filename_usedz$CodeTestCase.test_same_filename_used   sy    .Q&))]7=,,--< 	? 	?C#u~.. ?bnco>>>	? 	?r    N)r   r   r   r_   rc   rn   r   ru   r   cpython_onlyr~   r   r    r   r[   r[   p   s        " " "
, , ,0 0 0 / / /. ? ? ? ? ?r    r[   c            	       >    e Zd Zdddddgdddd	Zd
 Zd Zd Zd ZdS )ContainerTestCasezfoo@bar.baz.spamgHzns@   r$   .zyx.41)
r   r   r   r   r   r   r   r   r   r   FrH   )astringafloatanint
ashortlongalistatupleabooleanaunicodec                 :    |                      | j                   d S rW   )r   dr   s    r   	test_dictzContainerTestCase.test_dict   s    DFr    c                 x    |                      t          | j                                                             d S rW   )r   listr   itemsr   s    r   	test_listzContainerTestCase.test_list   s,    D(()))))r    c                 x    |                      t          | j                                                             d S rW   )r   tupler   keysr   s    r   
test_tuplezContainerTestCase.test_tuple   s,    E$&++--(()))))r    c                     t           t          fD ]7}|                      || j                                                             8d S rW   )set	frozensetr   r   r   )r   constructors     r   	test_setszContainerTestCase.test_sets   sI    + 	4 	4KKKDFKKMM223333	4 	4r    N)r   r   r   r   r   r   r   r   r   r    r   r   r      sv        &+"&	 	A  * * ** * *4 4 4 4 4r    r   c                        e Zd Zd Zd Zd ZdS )BufferTestCasec                     t          d          }|                     |           t          j        t          j        |                    }|                     t          |          t                     d S NrQ   )	bytearrayr   r   r   r   r   typebytesr   r;   r   s      r   test_bytearrayzBufferTestCase.test_bytearray   sY    fAmGM!,,--cE*****r    c                     t          d          }|                     |           t          j        t          j        |                    }|                     t          |          t                     d S r   )
memoryviewr   r   r   r   r   r   r   r   s      r   test_memoryviewzBufferTestCase.test_memoryview   sY    vAmGM!,,--cE*****r    c                     t          j         dd          }t          j        t          j        |                    }|                     |d           d S )NBrQ   )arrayr   r   r   r   )r   ar   s      r   
test_arrayzBufferTestCase.test_array   sH    KV$$mGM!,,--f%%%%%r    N)r   r   r   r   r   r   r   r    r   r   r      sA        + + ++ + +& & & & &r    r   c                   b    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S )BugsTestCasec                 6    t          j        dgdz             d S )N     )r   r   r   s    r   test_bug_5888452zBugsTestCase.test_bug_5888452   s    sedl#####r    c                 $   |                      t          t          j        d           |                      t          t          j        d           |                      t          t          j        t          j        ddz            d d                    d S )N   0   fr$   A   r0   )assertRaises	Exceptionr   r   r   r   s    r   test_patch_873224zBugsTestCase.test_patch_873224   sm    )W]D999)W]D999)W]GM!R%4H4H"4MNNNNNr    c                     |                      t          j        t          j        dd                    d           |                      t          j        t          j        dd                    d           d S )N   r   r%   )r   r   r   r   r   s    r   test_version_argumentz"BugsTestCase.test_version_argument   s`    w}Q':':;;Q???w}Q':':;;Q?????r    c                     t          d          D ]7}t          |g          }	 t          j        |           (# t          $ r Y 4w xY wd S )N   )ranger   r   r   r   )r   ics      r   	test_fuzzzBugsTestCase.test_fuzz   sh     s 	 	Aqc

Aa       		 	s   8
AAc                 \     d } |dt           j                    fd} |d|           d S )Nc                      |d| z  dz               |d| z  dz               |d| z  dz               |d| z  dz   d| z  z               |d| z  dz              d S )Ns   )   Ns   (   s   [   s   {Nr   s   >   r   )Nchecks     r   	run_testsz4BugsTestCase.test_loads_recursion.<locals>.run_tests   s    E(Q,%&&&E&*T1222E&*T1222E%!)d"TAX-...E&*T122222r    d   c                 T                         t          t          j        |            d S rW   r   
ValueErrorr   r   )r6   r   s    r   r   z0BugsTestCase.test_loads_recursion.<locals>.check   s#    j'-;;;;;r    r   )r   r   )r   r   r   s   `  r   test_loads_recursionz!BugsTestCase.test_loads_recursion   sY    		3 		3 		3 		#w}%%%	< 	< 	< 	< 	<	%r    c                    g x}}t           j        dk    rd}nt          j        dk    rd}nd}t	          |dz
            D ] }|                    dg           |d         }!t          j        |          }t          j        |          }| 	                    t          |          t          |                     | 	                    t          |d                   t          |d                              | 	                    t          |d                   t          |d                              |                    dg           |                     t          t          j        |           d S )	Nntr   wasii  i  r$   r   r0   )osnamer&   platformr   appendr   r   r   r   lenr   r   )r   headlastMAX_MARSHAL_STACK_DEPTHr   datanew_heads          r   test_recursion_limitz!BugsTestCase.test_recursion_limit   sH   t
 7d??&*##\V##&*##&*#.233 	 	AKK8DD }T""=&&XD		222Xa[))3tAw<<888Xb\**CRMM:::QC*gmT:::::r    c                     t           t          t          t          t          t
          t          t          fD ]B}t          d|fi           }| 	                    t          t          j         |                       Cd S )Nsubtyp)r1   r@   complexr   r   dictr   r   r   r   r   r   r   )r   typr   s      r   test_exact_type_matchz"BugsTestCase.test_exact_type_match  sj    
 dCK 	C 	CC (SFB//Fj'-BBBB		C 	Cr    c                 V    t          d          }d|z  }t          j        |           d S )Ng    .ArI   )r1   r   r   )r   size
testStrings      r   test_large_marshalzBugsTestCase.test_large_marshal&  s,    3xxT\
j!!!!!r    c                 V    d}|                      t          t          j        |           d S )Ns	   l       r   )r   invalid_strings     r   test_invalid_longszBugsTestCase.test_invalid_longs+  s'    =*gm^DDDDDr    c           	      R   ddddddddgff}d	D ]}t          |          }g }	 t          t          j        d
          5 }|D ]U}t	          j        ||           |r|                    |           |                    |                                           V	 d d d            n# 1 swxY w Y   t          t          j        d          5 }t          |          D ]r\  }}| 
                    |t	          j        |                     |r|                    |           | 
                    ||         |                                           s	 d d d            n# 1 swxY w Y   t          j        t          j                   u# t          j        t          j                   w xY wd S )Nr%   rI   s   def      ?r$   r   r;      c)r    s   0123r
   r   )r   r   r   r   r   r   writer   tell	enumerater   r   readr   )r   r   interleavedilen	positionsr   r   r   s           r   test_multiple_dumps_and_loadsz*BugsTestCase.test_multiple_dumps_and_loads0  s8    5&#3d'<=) 	3 	3K{##DI3)*D11 3Q! 3 3Q*** 1GGK000!((2222	33 3 3 3 3 3 3 3 3 3 3 3 3 3 3 )*D11 AQ )$ A A1((GLOO<<< )FF4LLL((1qvvxx@@@@	AA A A A A A A A A A A A A A A  !12222	 !12222#	3 	3sT   FAB$F$B(	(F+B(	,F	BEFE	F E	!F F$c                 V    d}|                      t          t          j        |           d S )NT)r   	TypeErrorr   r   )r   unicode_strings     r   !test_loads_reject_unicode_stringsz.BugsTestCase.test_loads_reject_unicode_stringsH  s'    )W]NCCCCCr    c           
           G d dt           j                  }dD ]C}|                     t          t          j         |t	          j        |                               Dd S )Nc                        e Zd Z fdZ xZS )/BugsTestCase.test_bad_reader.<locals>.BadReaderc                 d    t                                          |          }||dk    r|dz  }|S )N   i@B )superreadinto)r   bufr(   	__class__s      r   r   z8BugsTestCase.test_bad_reader.<locals>.BadReader.readintoO  s5    GG$$S))=QUUJAr    )r   r   r   r   __classcell__)r  s   @r   	BadReaderr   N  s8                r    r  )r   y              ?s
   0123456789
0123456789)ioBytesIOr   r   r   r   r   )r   r  values      r   test_bad_readerzBugsTestCase.test_bad_readerM  s    	 	 	 	 	
 	 	 	 < 	? 	?Ej','ie(<(<==? ? ? ?	? 	?r    c                     t          j        d          }t          t          |                    D ]0}|                     t
          t           j        |d|                    1d S )N)hellodollyNr   )r   r   r   r   r   EOFErrorr   )r   r   r   s      r   test_eofzBugsTestCase.test_eofX  sb    }566s4yy!! 	C 	CAhtAqDzBBBB	C 	Cr    c                    dD ]}dD ]}| d| d}|                      |          5  t          j        j        dv r>dd| dg}t	          |d	d
i\  }}}t	          |d	di\  }}}|                     ||           dd| dg}t	          |d	d
i\  }}}t	          |d	di\  }}	}|                     ||	           d d d            n# 1 swxY w Y   ǌd S )N)r   r   )z-float('nan'), b'a', b'b', b'c', 'x', 'y', 'z'zL('Spam', 0), ('Spam', 1), ('Spam', 2), ('Spam', 3), ('Spam', 4), ('Spam', 5)z([z])>   fnv	siphash24rq   zprint()PYTHONHASHSEED01z$import marshal; print(marshal.dumps(z)))subTestr&   	hash_info	algorithmr   assertNotEqualr   )
r   kindelementsr6   args_repr_0repr_1dump_0dump_1s
             r   test_deterministic_setsz$BugsTestCase.test_deterministic_sets]  sx    ) 	5 	5D 5 5
 ++x+++\\!__ 5 5 }.2FFF $mqmmm4'7'Rc'R'R61'7'Rc'R'R61++FF;;; "N"N"N"NOD#3T#N##N#NLAvq#3T#N##N#NLAvq$$VV4445 5 5 5 5 5 5 5 5 5 5 5 5 5 55	5 	5s   BCC	CN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	  r  r"  r   r    r   r   r      s        $ $ $O O O
@ @ @
       &; ; ;8	C 	C 	C" " "
E E E
3 3 30D D D
	? 	? 	?C C C
5 5 5 5 5r    r   l        l    r-   r   c                       e Zd Zd ZdS )
NullWriterc                     d S rW   r   rL   s     r   r   zNullWriter.write}  s    r    N)r   r   r   r   r   r    r   r$  r$  |  s#            r    r$  z!test cannot run on 32-bit systemsc                      e Zd Zd Z ej        edd          d             Z ej        edd          d             Z ej        ee	dz   d          d             Z
 ej        ee	dz   d          d	             Z ej        ee	d
z   ej        edz
            z   d          d             Z ej        ee	d
z   ej        edz
            z   d          d             Z ej        edd          d             ZdS )LargeValuesTestCasec                 l    |                      t          t          j        |t	                                 d S rW   )r   r   r   r   r$  )r   r   s     r   check_unmarshallablez(LargeValuesTestCase.check_unmarshallable  s(    *glD*,,GGGGGr    r$   F)r   memusedry_runc                 6    |                      d|z             d S )N   xr)  r   r   s     r   rS   zLargeValuesTestCase.test_bytes  s     !!$+.....r    c                 6    |                      d|z             d S )Nre   r.  r/  s     r   test_strzLargeValuesTestCase.test_str  s     !!#*-----r    r%   c                 6    |                      d|z             d S )NrW   r.  r/  s     r   r   zLargeValuesTestCase.test_tuple  s     !!'D.11111r    c                 8    |                      d g|z             d S rW   r.  r/  s     r   r   zLargeValuesTestCase.test_list  s"    !!4&4-00000r       c                 d    |                      t          t          |                               d S rW   )r)  r   r   r/  s     r   test_setzLargeValuesTestCase.test_set  s,     	!!#eDkk"2"233333r    c                 d    |                      t          t          |                               d S rW   )r)  r   r   r/  s     r   test_frozensetz"LargeValuesTestCase.test_frozenset  s,     	!!)E$KK"8"899999r    c                 J    |                      t          |                     d S rW   )r)  r   r/  s     r   r   z"LargeValuesTestCase.test_bytearray  s"    !!)D//22222r    N)r   r   r   r)  r   
bigmemtest
LARGE_SIZErS   r1  pointer_sizer   r   r&   	getsizeofr6  r8  r   r   r    r   r'  r'    s       H H H WZ5AAA/ / BA/ WZ5AAA. . BA. WZq0@%PPP2 2 QP2 WZq0@%PPP1 1 QP1 WZ?]S]:a<%@%@@  4 4 4 WZ?]S]:a<%@%@@  : : : WZ5AAA3 3 BA3 3 3r    r'  c                    	 t          |          | v rd S |                     t          |                     t          |t          t          t
          t          f          r|D ]}t          | |           nOt          |t                    r:|	                                D ]%\  }}t          | |           t          | |           &t          |           S rW   )idaddry   r   r   r   r   CollectObjectIDsr   r   r   )idsr}   ekvs        r   rA  rA    s    0	#ww#~~GGBsGG#eS)455 % 	% 	%AS!$$$$	%	C		 %IIKK 	% 	%DAqS!$$$S!$$$$s88Or    c                   |    e Zd Zdddd eddh          fZ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S )InstancingTestCase{   獗n?rI   )rH  rI   Fc                    ||f}t          t                      |          }t          dt          j        dz             D ][}t          j        ||          }t          t                      t          j        |                    }|                     ||           \|st          j        |d          }	t          t                      t          j        |	                    }
|                     |
|           |s2|                     t          |	          t          |                     d S | 
                    t          |	          t          |                     d S d S )N   r%   r$   )rA  r   r   r   versionr   r   r   assertGreaterr   assertGreaterEqual)r   rsample	recursivesimpler   n0rE  s3n3s2n2s              r   helper3zInstancingTestCase.helper3  s8   7#ceeV,,q'/A-.. 	% 	%Avq))B!#%%r):):;;B R$$$$ 	:vq))B!#%%r):):;;Br2&&&  :""3r77CGG44444''BR99999	: 	:r    c                 b    d}|                      |           |                     |d           d S )Ni T)rQ  r   rW  )r   intobjs     r   testIntzInstancingTestCase.testInt  s5    FVD)))))r    c                 ^    d}|                      |           |                     |           d S )NrI  rY  )r   floatobjs     r   	testFloatzInstancingTestCase.testFloat  s1    HXr    c                 ^    d}|                      |           |                     |           d S )NabcdeabcdeabcderY  )r   strobjs     r   testStrzInstancingTestCase.testStr  s1    FVr    c                 ^    d}|                      |           |                     |           d S )Ns   abcdeabcdeabcderY  )r   bytesobjs     r   	testByteszInstancingTestCase.testBytes  s1    HXr    c                 v    | j         D ]0}||g}|                     |           |                     |           1d S rW   r   r   rW  )r   r}   listobjs      r   testListzInstancingTestCase.testList  sM    9 	" 	"CCjGKK   LL!!!!	" 	"r    c                 v    | j         D ]0}||f}|                     |           |                     |           1d S rW   rg  )r   r}   tupleobjs      r   	testTuplezInstancingTestCase.testTuple  sM    9 	# 	#CSzHKK!!!LL""""	# 	#r    c                 ~    | j         D ]4}|df|dfh}|                     |           |                     |           5d S Nr%   r$   rg  )r   r}   setobjs      r   testSetzInstancingTestCase.testSet  sV    9 	! 	!CAha)FKKLL    	! 	!r    c                     | j         D ]A}t          |df|dfh          }|                     |           |                     |           Bd S rn  )r   r   r   rW  )r   r}   frozensetobjs      r   testFrozenSetz InstancingTestCase.testFrozenSet  s^    9 	' 	'C$sAha%9::LKK%%%LL&&&&	' 	'r    c                 ~    | j         D ]4}d|d||di}|                     |           |                     |           5d S )Nr  goodbyerg  )r   r}   dictobjs      r   testDictzInstancingTestCase.testDict  sV    9 	" 	"CYS'BGKK   LL!!!!	" 	"r    c                 <   t          t          d          5 }|                                }d d d            n# 1 swxY w Y   t                              d          rt	          |t          d          }|                     |           |                     |           d S Nr   z.pyrg   )r   __file__r   endswithrj   r   rW  )r   r   rt   s      r   
testModulezInstancingTestCase.testModule  s    (D!! 	Q6688D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	U## 	34622DDT   7;;c                     d}d|d||di}||d<   |                      |d           ||g}|                    |           |                      |d           d S )NrI  r  ru  r   T)rP  )rW  r   )r   r}   r   ls       r   testRecursionz InstancingTestCase.testRecursion
  sl    c9c38&	Q$'''#J	Q$'''''r    N)FF)r   r   r   r   r   rW  r[  r^  rb  re  ri  rl  rp  rs  rw  r|  r  r   r    r   rG  rG    s        iie.E.EFD: : : :4* * *
  
  
  
" " "# # #! ! !' ' '" " "  ( ( ( ( (r    rG  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )CompatibilityTestCasec                 :   t          t          d          5 }|                                }d d d            n# 1 swxY w Y   t                              d          rt	          |t          d          }t          j        ||          }t          j        |           d S ry  )r   rz  r   r{  rj   r   r   r   )r   rL  r   rt   r   s        r   _testzCompatibilityTestCase._test  s    (D!! 	Q6688D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	U## 	34622D}T7++dr}  c                 0    |                      d           d S )Nr   r  r   s    r   test0To3zCompatibilityTestCase.test0To3      

1r    c                 0    |                      d           d S )Nr%   r  r   s    r   test1To3zCompatibilityTestCase.test1To3  r  r    c                 0    |                      d           d S Nr$   r  r   s    r   test2To3zCompatibilityTestCase.test2To3"  r  r    c                 0    |                      d           d S )NrK  r  r   s    r   test3To3zCompatibilityTestCase.test3To3%  r  r    N)r   r   r   r  r  r  r  r  r   r    r   r  r    s_                    r    r  c                   >    e Zd ZdZ ej        e          Zd Zd ZdS )InterningTestCasezthis is an interned stringc                    t          j        t          j        | j                            }|                     || j                   |                     t          |          t          | j                             t          j        |          }|                     t          |          t          |                     d S rW   )r   r   r   ra  r   r?  r&   internr   r6   rU  s      r   
testInternzInterningTestCase.testIntern,  s    M'-4455DK(((A4;000Z]]BA'''''r    c                    t          j        t          j        | j        d                    }|                     || j                   |                     t          |          t          | j                             t          j        |          }|                     t          |          t          |                     d S r  )	r   r   r   ra  r   r  r?  r&   r  r  s      r   testNoInternzInterningTestCase.testNoIntern3  s    M'-Q7788DK(((BqEE2dk??333Z]]BrFFBqEE*****r    N)r   r   r   ra  r&   r  r  r  r   r    r   r  r  (  sH        )FSZF( ( (+ + + + +r    r  zrequires _testcapic                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )CAPI_TestCasec                 x   t          t          j        dz             D ]}t          j        dt
          j        |           t          t
          j        d          5 }|                                }d d d            n# 1 swxY w Y   t          j	        t
          j                   | 
                    |d           d S )Nr%   xV4r   s   xV4)r   r   rL  	_testcapipymarshal_write_long_to_filer   r   r   r   r   r   )r   rE  r   r   s       r   test_write_long_to_filez%CAPI_TestCase.test_write_long_to_file>  s    w*++ 	8 	8A2:y?OQRSSSi&--  vvxx                             Y-...T#67777	8 	8s   A::A>	A>	c                    dddddddz  f}t          t          j        dz             D ]}t          j        |t
          j        |           t          t
          j        d	          5 }|                                }d d d            n# 1 swxY w Y   t          j	        t
          j                   | 
                    t          j        |          |           d S )
N   €rQ   rH  F@      @       @z
long line r   r%   r   )r   r   rL  r  pymarshal_write_object_to_filer   r   r   r   r   r   r   )r   r}   rE  r   r   s        r   test_write_object_to_filez'CAPI_TestCase.test_write_object_to_fileF  s   dD,t2CDw*++ 	7 	7A4S):JANNNi&--  vvxx                             Y-...W]400#6666	7 	7s   $BB		B		c                    t          t          j        d          5 }|                    d           d d d            n# 1 swxY w Y   t	          j        t          j                  \  }}t          j        t          j                   |                     |d           |                     |d           t          t          j        d          5 }|                    d           d d d            n# 1 swxY w Y   |                     t                    5  t	          j        t          j                   d d d            n# 1 swxY w Y   t          j        t          j                   d S )Nr
   s   4xxxxi4  r$      )
r   r   r   r   r  pymarshal_read_short_from_filer   r   r   r  r   r   rps       r   test_read_short_from_filez'CAPI_TestCase.test_read_short_from_fileO  s   )"D)) 	%QGGO$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%7	8HII1)***F###A)"D)) 	QGGG	 	 	 	 	 	 	 	 	 	 	 	 	 	 	x(( 	G 	G4Y5EFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G)*****3   =AAC//C36C3D??EEc                    t          t          j        d          5 }|                    d           d d d            n# 1 swxY w Y   t	          j        t          j                  \  }}t          j        t          j                   |                     |d           |                     |d           t          t          j        d          5 }|                    d           d d d            n# 1 swxY w Y   |                     t                    5  t	          j        t          j                   d d d            n# 1 swxY w Y   t          j        t          j                   d S )Nr
   s   xV4xxxxr  r   s   V4)
r   r   r   r   r  pymarshal_read_long_from_filer   r   r   r  r  s       r   test_read_long_from_filez&CAPI_TestCase.test_read_long_from_file]  s   )"D)) 	-QGG+,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-6y7GHH1)***J'''A)"D)) 	%QGGO$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%x(( 	F 	F3I4DEEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F)*****r  c                 .   d}t          t          j        dz             D ]t}t          j        ||          }t	          t
          j        d          5 }|                    |dz              d d d            n# 1 swxY w Y   t          j	        t
          j                  \  }}t          j
        t
          j                   |                     ||           t	          t
          j        d          5 }|                    |d d                    d d d            n# 1 swxY w Y   |                     t                    5  t          j	        t
          j                   d d d            n# 1 swxY w Y   t          j
        t
          j                   vd S N)r  rQ   rH  r  r  r%   r
   s   xxxx)r   r   rL  r   r   r   r   r   r  $pymarshal_read_last_object_from_filer   r   r   r  r   r}   rE  r   r   r  r  s          r   test_read_last_object_from_filez-CAPI_TestCase.test_read_last_object_from_filek  s    1w*++ 	/ 	/A=a((Di&-- (w'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (A)BRSSDAqY-...Q$$$i&-- "RaR!!!" " " " " " " " " " " " " " """8,, Q Q>y?OPPPQ Q Q Q Q Q Q Q Q Q Q Q Q Q QY-....	/ 	/s6   A66A:	=A:	0DD	!D	?E**E.	1E.	c                 t   d}t          t          j        dz             D ]}t          j        ||          }t	          t
          j        d          5 }|                    |dz              d d d            n# 1 swxY w Y   t          j	        t
          j                  \  }}t          j
        t
          j                   |                     ||           |                     |t          |                     t	          t
          j        d          5 }|                    |d d                    d d d            n# 1 swxY w Y   |                     t                    5  t          j	        t
          j                   d d d            n# 1 swxY w Y   t          j
        t
          j                   d S r  )r   r   rL  r   r   r   r   r   r  pymarshal_read_object_from_filer   r   r   r   r  r  s          r   test_read_object_from_filez(CAPI_TestCase.test_read_object_from_file{  s<   1w*++ 	/ 	/A=a((Di&-- (w'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (<Y=MNNDAqY-...Q$$$QD		***i&-- "RaR!!!" " " " " " " " " " " " " " """8,, L L9):JKKKL L L L L L L L L L L L L L LY-....	/ 	/s6   A66A:	=A:	D==E	E	"FF	F	N)	r   r   r   r  r  r  r  r  r  r   r    r   r  r  :  sn        8 8 87 7 7+ + ++ + +/ / / / / / / /r    r  __main__)*testr   test.supportr   r   test.support.script_helperr   r   r  r   r&   unittestr   rz   rr   r  ImportErrorr   TestCaser"   r>   rD   rU   r[   r   r   r   r;  r'   r<  r$  skipIfr'  rA  rG  r  r  r   
skipUnlessr  r   mainr   r    r   <module>r     s(         9 9 9 9 9 9 9 9 7 7 7 7 7 7  				  



  				     III/ / / / / / / /" " " " "(#[ " " "H    H%{   6    X&   - - - - -) - - -
2? 2? 2? 2? 2?8$ 2? 2? 2?h4 4 4 4 4); 4 4 42& & & & &X& & & &(f5 f5 f5 f5 f58$ f5 f5 f5P 
K*,,qq!        ck)+NOO"3 "3 "3 "3 "3(+ "3 "3 PO"3H  ^( ^( ^( ^( ^(*K ^( ^( ^(@    H-   *+ + + + +); + + +$ 	Y 455N/ N/ N/ N/ N/H%{ N/ N/ 65 N/b zHMOOOOO s   ; AA