HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_ordered_dict.cpython-37.opt-1.pyc
B

��g�u�@s�ddlZddlZddlZddlZddlZddlmZmZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZejddgd�Zejddgd�Zejd	d
��ZGdd�d�ZGd
d�dee
j�ZGdd�de
j�Zx"d��D]Zeeeeee��q�W[e
�ed�Gdd�dee
j��ZGdd�de�Z Gdd�de�Z!Gdd�dej"�Z#e
�ed�Gdd�dej"��Z$Gdd�dej"�Z%e
�ed�Gdd �d ej"��Z&e'd!k�r�e
�(�dS)"�N)�	randrange�shuffle)�MutableMapping)�
mapping_tests�support�collections�_collections)Zblocked)Zfreshc	cs0tj|}|tj|<z
dVWd|tj|<XdS)N)�sys�modules)�nameZreplacementZoriginal_module�r�2/usr/local/lib/python3.7/test/test_ordered_dict.py�replaced_modules



rc@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]S)^�OrderedDictTestsc
Cs`|j}|�t��|ddgd�WdQRXdddddg}|�t|t|�����|�|�t|ft|�����|�|�t||����|�|�t|ddddgddd	����|�|�t|d
d����dg�|�t|d
d
����dg�|�t|d
�|�t|dd�|�t|j�|dddddg�}|jddgddd�|�t|���dddddddg�dS)N)�a�)�b�)�c�)�d�)�e�)r�	rr)rr�*)�self)rr)�other)rrr)r�,)r�7)�f��r)�gr)r#r")	�OrderedDict�assertRaises�	TypeError�assertEqual�sorted�dict�items�list�__init__)rr$�pairsrrrr
�	test_inits$zOrderedDictTests.test_initcCsJ|j}dddddddg}t|�||�}|f|�}|�t|���|�dS)N)rr)rr)rr)rr)rr)r r!)r#r")r$rr'r+r*)rr$r*Zargdictrrrr
�test_4687s
zOrderedDictTests.test_468c
Cs$|j}|�t��|��ddgd�WdQRXdddddg}|�}|�t|��|�t|���|�|�}|jft|��|�t|���|�|�}|�|�|�t|���|�|�}|jddddgddd	�|�t|���|�|�}|jd
d�|�t|���dg�|�}|jid
�|�t|���difg�|�}|jddddd�|�tt|����ddddg�|dddddg�}|jddgddd�|�t|���dddddddg�|�t|�jd�|�t|�jdd�|�t|j�|�t|�jd�|�t|�jdd�|�t|j�dS)N)rr)rr)rr)rr)rr)rrrr)rr�)r)rr0)rrr!r"�)�red�bluerr)r3r!)rr")r2r)rr1)rr)rr)r r!r)r#r)r#r"rr)	r$r%r&�updater)r'r(r*r+)rr$r-�odrrrr
�test_update?sH
zOrderedDictTests.test_updatecs4g�G�fdd�d�}|�|��|��dg�dS)Ncs$eZdZ�fdd�Z�fdd�ZdS)z.OrderedDictTests.test_init_calls.<locals>.Spamcs��d�dS)N�keysr)�append)r)�callsrr
r7ps
z3OrderedDictTests.test_init_calls.<locals>.Spam.keyscs��d�dS)Nr*r)r8)r)r9rr
r*ss
z4OrderedDictTests.test_init_calls.<locals>.Spam.itemsN)�__name__�
__module__�__qualname__r7r*r)r9rr
�Spamosr=r7)r$r')rr=r)r9r
�test_init_callsmsz OrderedDictTests.test_init_callscCs�|j}|�d�}|�t|���dd�dD��|jddd�}|�t|���dd�dD��|jddd�}|�t|���dd�dD��dS)N�abccSsg|]}|df�qS)Nr)�.0rrrr
�
<listcomp>}sz2OrderedDictTests.test_fromkeys.<locals>.<listcomp>)�valuecSsg|]}|df�qS)Nr)r@rrrr
rAsrcSsg|]}|df�qS)rr)r@rrrr
rA�s)r$�fromkeysr'r+r*)rr$r5rrr
�
test_fromkeyszs
zOrderedDictTests.test_fromkeyscCs(|j}|�|�t�|�t|t��dS)N)r$�assertIsInstancer�
assertTrue�
issubclass)rr$rrr
�test_abc�szOrderedDictTests.test_abccCsV|j}ddddddg}t|�||�}|�t|�t|��|��|�t|�d�dS)N)rr)rr)rr)rr)rr)r r!r)r$rr'�len�clear)rr$r-r5rrr
�
test_clear�szOrderedDictTests.test_clearc	Csx|j}ddddddg}||�}|d=|�d|�|�t��|d=WdQRX|�t|���|dd�|d	d��dS)
N)rr)rr)rr)rr)rr)r r!rrr)r$�assertNotInr%�KeyErrorr'r+r*)rr$r-r5rrr
�test_delitem�szOrderedDictTests.test_delitemc	CsL|j}|dddddg�}d|d<d|d	<|�t|���ddd
dddg�dS)N)rr)rr)rr)rr)rr�
r�r )rrO)r rP)r$r'r+r*)rr$r5rrr
�test_setitem�szOrderedDictTests.test_setitemcCs"|j}ddddddg}t|�||�}|�t|�dd�|D��|�t|���d	d�|D��|�t|���d
d�|D��|�t|���|�|�tt|��dd�t|�D��|�tt|����dd�t|�D��|�tt|����d
d�t|�D��|�tt|����tt|���dS)N)rr)rr)rr)rr)rr)r r!cSsg|]}|d�qS)rr)r@�trrr
rA�sz3OrderedDictTests.test_iterators.<locals>.<listcomp>cSsg|]}|d�qS)rr)r@rRrrr
rA�scSsg|]}|d�qS)rr)r@rRrrr
rA�scSsg|]}|d�qS)rr)r@rRrrr
rA�scSsg|]}|d�qS)rr)r@rRrrr
rA�scSsg|]}|d�qS)rr)r@rRrrr
rA�s)r$rr'r+r7�valuesr*�reversed)rr$r-r5rrr
�test_iterators�szOrderedDictTests.test_iteratorsc	CsH|j}|�d�}t|�}t|�}||=|�t��t|�WdQRXdS)Nr?)r$rC�iter�nextr%�	Exception)rr$r5�it�keyrrr
�%test_detect_deletion_during_iteration�s
z6OrderedDictTests.test_detect_deletion_during_iterationc	Cs�|j}|�t��|ddgd�WdQRXdddddg}||�}|�t|�dd�|D��|�t|���dd�|D��|�t|���d	d�|D��|�t|���|�|�tt|��td
d�t|�D���dS)N)rr)rr)rr)rr)rrcSsg|]}|d�qS)rr)r@rRrrr
rA�sz:OrderedDictTests.test_sorted_iterators.<locals>.<listcomp>cSsg|]}|d�qS)rr)r@rRrrr
rA�scSsg|]}|d�qS)rr)r@rRrrr
rA�scSsg|]}|d�qS)rr)r@rRrrr
rA�s)	r$r%r&r'r(r7rSr*rT)rr$r-r5rrr
�test_sorted_iterators�sz&OrderedDictTests.test_sorted_iteratorscCs�|j}|�}g}|�t|�|�|�t|���|�|�t|���|�|�t|���|�|�tt|��|�|�tt|����|�|�tt|����|�|�tt|����|�dS)N)r$r'r+r7rSr*rT)rr$r5�emptyrrr
�test_iterators_empty�sz%OrderedDictTests.test_iterators_emptyc	Csv|j}ddddddg}t|�||�}x|rB|�|��|���q(W|�t��|��WdQRX|�t|�d�dS)N)rr)rr)rr)rr)rr)r r!r)r$rr'�popitem�popr%rMrI)rr$r-r5rrr
�test_popitem�szOrderedDictTests.test_popitemcCsf|j}dd�td�D�}||�}xtd�D]}|�d�q*W|�d�|jdd�|�t|�d�dS)NcSsg|]}||f�qSrr)r@�irrr
rA�sz6OrderedDictTests.test_popitem_last.<locals>.<listcomp>�r1T)�lastrP)r$�ranger_r'rI)rr$r-�objrbrrr
�test_popitem_last�s
z"OrderedDictTests.test_popitem_lastc	Cs*|j}ddddddg}t|�||�}t|�x&|rT|��\}}|�|�|�|�q0W|�t��|�d�WdQRX|�t|�d�|�|�|d	�d	�Gd
d�d|�}|dd
�}|�|�dd�d�|�|�dd�d�|�|�dd�d�|�|jddd�d�|�t��|�d�WdQRXdS)N)rr)rr)rr)rr)rr)r r!Zxyzri90c@seZdZdd�ZdS)z*OrderedDictTests.test_pop.<locals>.MissingcSsdS)Nrr)rrZrrr
�__missing__�sz6OrderedDictTests.test_pop.<locals>.Missing.__missing__N)r:r;r<rhrrrr
�Missing�srir)rrrrr!)�default)r$rr`r'r%rMrI)rr$r-r5�k�vri�mrrr
�test_pop�s(
zOrderedDictTests.test_popcCs�|j}ddddddg}t|�||�}||�}|�||�|dd�|dd�}||�}|�||�|�|t|��|�t|�|�|�|||dd���dS)	N)rr)rr)rr)rr)rr)r r!r���)r$rr'ZassertNotEqualr))rr$r-Zod1Zod2rrr
�
test_equality	szOrderedDictTests.test_equalitycs��j}ddddddg}||����fdd�}|����|t����|t����td	�j��LxDttjd
�D]2}�j|d��|t�	t�
�|���WdQRXqrWWdQRX|tt����|�}|�
��||�||���dS)N)rr)rr)rr)rr)rr)r r!csnd|�f}��|�|���|����t|���t�������t|�t�����t|�t���dS)Nz
copy: %s
od: %s)�assertIsNotr'r+r*rI�type)�dup�msg)r5rrr
�checksz,OrderedDictTests.test_copying.<locals>.checkrr)�proto)r$�copyZdeepcopyr�modulere�pickle�HIGHEST_PROTOCOL�subTest�loads�dumps�eval�reprr4)rr$r-rurvZupdate_testr)r5rr
�test_copyings .
zOrderedDictTests.test_copyingcCsB|j}ddddddg}||�}|�tdd�|��d	D���dS)
N)rr)rr)rr)rr)rr)r r!css|]}t|�tkVqdS)N)rrr+)r@Zpairrrr
�	<genexpr><sz5OrderedDictTests.test_yaml_linkage.<locals>.<genexpr>r)r$rF�all�
__reduce__)rr$r-r5rrr
�test_yaml_linkage4sz"OrderedDictTests.test_yaml_linkagecCsr|j}ddddddg}||�}|�|jt�|�|��d�d|_|�|jd	d�|�|��dd	di�dS)
N)rr)rr)rr)rr)rr)r r!rrO�x)r$rE�__dict__r)�assertIsNoner�r�r')rr$r-r5rrr
�test_reduce_not_too_fat>sz(OrderedDictTests.test_reduce_not_too_fatc	Cs�|j}|�}||d<td|j��dx\tdtjd�D]H}t�t�||��}|�||�|�	t
|���dg�|�|d|�q4WWdQRXdS)Nrrro)
r$rrxreryrzr|r}rqr'r+r7ZassertIs)rr$r5rvrsrrr
�test_pickle_recursiveIsz&OrderedDictTests.test_pickle_recursivecCsT|j}|ddddddg�}|�t|�d�|�tt|��|�|�t|��d�dS)	N)rr)rr)rr)rr)rr)r r!zIOrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)])z
OrderedDict())r$r'rr~)rr$r5rrr
�	test_reprVs
zOrderedDictTests.test_reprcCs,|j}|�d�}||d<|�t|�d�dS)Nr?r�z@OrderedDict([('a', None), ('b', None), ('c', None), ('x', ...)]))r$rCr'r)rr$r5rrr
�test_repr_recursive^s


z$OrderedDictTests.test_repr_recursivecCsP|j}|�}|��|d<t|�}|�|t�|��|d<t|�}|�|t�dS)Nr)r$rSrrE�strr*)rr$r5�rrrr
�test_repr_recursive_valuesfsz+OrderedDictTests.test_repr_recursive_valuescCs�|j}ddddddg}t|�||�}t|���}|�|�dd�d	�|�t|���|�|�|�d
d�d�|�t|���dd�|�|jd
dd�d�Gdd�d|�}|�|��dd�d�dS)N)rr)rr)rr)rr)rr)r r!rrOrr�ro)r�rOr#r)rjc@seZdZdd�ZdS)z1OrderedDictTests.test_setdefault.<locals>.MissingcSsdS)Nrr)rrZrrr
rh�sz=OrderedDictTests.test_setdefault.<locals>.Missing.__missing__N)r:r;r<rhrrrr
ri�srir)r$rr+r*r'�
setdefault)rr$r-r5Z
pair_orderrirrr
�test_setdefaulttsz OrderedDictTests.test_setdefaultcCs\|j}|�}d|d<d|d<|d=|�t|���dg�d|d<|�t|���ddg�dS)Nrrrr)rr)rr)r$r'r+r*)rr$r5rrr
�
test_reinsert�szOrderedDictTests.test_reinsertc	Cs|j}|�d�}|�t|�td��|�d�|�t|�td��|�dd�|�t|�td��|�dd�|�t|�td��|�d�|�t|�td��|jddd	�|�t|�td
��|�t��|�d�WdQRX|�t��|�dd�WdQRXdS)N�abcderZabdecrZcabderrF)rdZbcader�)r$rCr'r+�move_to_endr%rM)rr$r5rrr
�test_move_to_end�s"


z!OrderedDictTests.test_move_to_endcCs�|j}|�d�}|jddd�|�t|�td��|jddd�|�t|�td��|�d�}|�d�|�t|�td��|�d�|�t|�td	��dS)
Nr?rF)rdZcabrZacbZbcaZbac)r$rCr�r'r+)rr$r5rrr
�test_move_to_end_issue25406�s



z,OrderedDictTests.test_move_to_end_issue25406cCs6|j}tdd�}|f|�}|�t�|�t�|��dS)Nr)r)r$r)Z
assertGreaterr	�	getsizeof)rr$rr5rrr
�test_sizeof�s

zOrderedDictTests.test_sizeofcCsL|j}d��}|�|�}|�|��t|����|�|��t|����dS)Nz@the quick brown fox jumped over a lazy dog yesterday before dawn)r$�splitrCr'r7r)r*)rr$�sr5rrr
�
test_views�s

zOrderedDictTests.test_viewscCs<|j}Gdd�d|�}dddg}|�t||����|�dS)Nc@seZdZdd�ZdS)z3OrderedDictTests.test_override_update.<locals>.MyODc_s
t��dS)N)rX)r�args�kwdsrrr
r4�sz:OrderedDictTests.test_override_update.<locals>.MyOD.updateN)r:r;r<r4rrrr
�MyOD�sr�)rr)rr)rr)r$r'r+r*)rr$r�r*rrr
�test_override_update�s
z%OrderedDictTests.test_override_updatecCs8|j}d}xtd�D]}|d|fg�}qW~t��dS)Ni�)r$rer�
gc_collect)rr$rf�_rrr
�test_highly_nested�sz#OrderedDictTests.test_highly_nestedcsn|j}g�G�fdd�d|�}d}x$td�D]}|d|fg�}||_q,W~t��|��tttd����dS)NcseZdZ�fdd�ZdS)z:OrderedDictTests.test_highly_nested_subclass.<locals>.MyODcs��|j�dS)N)r8rb)r)�deletedrr
�__del__�szBOrderedDictTests.test_highly_nested_subclass.<locals>.MyOD.__del__N)r:r;r<r�r)r�rr
r��sr��d)r$rerbrr�r'r+rT)rr$r�rfrbr)r�r
�test_highly_nested_subclass�s
z,OrderedDictTests.test_highly_nested_subclassc	Cs�|j}Gdd�d�}dd�}d}||�}||�}|||��}|�}d||<d||<d||<d|d<||=||=|�t|���|dfdg�dS)	Nc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
z9OrderedDictTests.test_delitem_hash_collision.<locals>.KeycSs||_tt|��|_dS)N)�_hashr��idrB)r�hashrrr
r,�szBOrderedDictTests.test_delitem_hash_collision.<locals>.Key.__init__cSs|jS)N)r�)rrrr
�__hash__�szBOrderedDictTests.test_delitem_hash_collision.<locals>.Key.__hash__cSs&y|j|jkStk
r dSXdS)NF)rB�AttributeError)rrrrr
�__eq__�sz@OrderedDictTests.test_delitem_hash_collision.<locals>.Key.__eq__cSs|jS)N)rB)rrrr
�__repr__�szBOrderedDictTests.test_delitem_hash_collision.<locals>.Key.__repr__N)r:r;r<r,r�r�r�rrrr
�Key�sr�cSs$d}||d@}|d>||dS)Nr1rrr)r�ZMINSIZErbrrr
�
blocking_hash�szCOrderedDictTests.test_delitem_hash_collision.<locals>.blocking_hashr.�after)r�.)r$r'r+r*)	rr$r�r�Z	COLLIDINGrZZ	collidingZblockingr5rrr
�test_delitem_hash_collision�sz,OrderedDictTests.test_delitem_hash_collisionc	Cs�|j}Gdd�d�}|�}xtd�D]}|�}|||<q$W|�t��t|���WdQRX|�t��t|���WdQRX|�t��t|�WdQRX|�t��|��WdQRXdS)Nc@seZdZdd�ZdS)z-OrderedDictTests.test_issue24347.<locals>.KeycSstd�S)Ni��)r)rrrr
r�sz6OrderedDictTests.test_issue24347.<locals>.Key.__hash__N)r:r;r<r�rrrr
r�sr�r�)	r$rer%rMr+rSr*rrw)rr$r�r5rbrZrrr
�test_issue24347sz OrderedDictTests.test_issue24347cCs0|j}Gdd�d�}|�}d||�<|��dS)Nc@seZdZdd�ZdS)z-OrderedDictTests.test_issue24348.<locals>.KeycSsdS)Nrr)rrrr
r�&sz6OrderedDictTests.test_issue24348.<locals>.Key.__hash__N)r:r;r<r�rrrr
r�%sr�r)r$r_)rr$r�r5rrr
�test_issue24348"s

z OrderedDictTests.test_issue24348cCsT|j}|�}xBdD]:}x4dD],}t|�dkr8|jdd�||}|||<qWqWdS)a�
        dict resizes after a certain number of insertion operations,
        whether or not there were deletions that freed up slots in the
        hash table.  During fast node lookup, OrderedDict must correctly
        respond to all resizes, even if the current "size" is the same
        as the old one.  We verify that here by forcing a dict resize
        on a sparse odict and then perform an operation that should
        trigger an odict resize (e.g. popitem).  One key aspect here is
        that we will keep the size of the odict the same at each popitem
        call.  This verifies that we handled the dict resize properly.
        Z0123456789ABCDEFrF)rdN)r$rIr_)rr$r5Zc0Zc1rZrrr
�test_issue24667.s

z OrderedDictTests.test_issue24667cCs.|j}|�}t�|dd�|�dt|��dS)N�spamr�NULL)r$r)�__setitem__rLr)rr$r5rrr
�test_dict_setitemGsz"OrderedDictTests.test_dict_setitemc	CsJ|j}|�}d|d<d|d<t�|d�|�t��t|�WdQRXdS)Nrr�r�ham)r$r)�__delitem__r%rMr)rr$r5rrr
�test_dict_delitemMsz"OrderedDictTests.test_dict_delitemcCs:|j}|�}d|d<d|d<t�|�|�dt|��dS)Nrr�rr�r�)r$r)rJrLr)rr$r5rrr
�test_dict_clearVs
z OrderedDictTests.test_dict_clearc	CsJ|j}|�}d|d<d|d<t�|d�|�t��t|�WdQRXdS)Nrr�rr�)r$r)r`r%rMr)rr$r5rrr
�
test_dict_pop^szOrderedDictTests.test_dict_popc	CsH|j}|�}d|d<d|d<t�|�|�t��t|�WdQRXdS)Nrr�rr�)r$r)r_r%rMr)rr$r5rrr
�test_dict_popitemgs
z"OrderedDictTests.test_dict_popitemcCs.|j}|�}t�|dd�|�dt|��dS)Nr�rr�)r$r)r�rLr)rr$r5rrr
�test_dict_setdefaultpsz%OrderedDictTests.test_dict_setdefaultcCs.|j}|�}t�|dg�|�dt|��dS)N)r�rr�)r$r)r4rLr)rr$r5rrr
�test_dict_updatevsz!OrderedDictTests.test_dict_updatecsF|j�G�fdd�d�}d|j|<t�|�}~t��|�|��dS)NcseZdZ��ZdS)z/OrderedDictTests.test_reference_loop.<locals>.AN)r:r;r<r5r)r$rr
�Asr�)r$r5�weakref�ref�gc�collectr�)rr�r�r)r$r
�test_reference_loop|s

z$OrderedDictTests.test_reference_loopcCsPt�|t|j�t�|dd�|j�t�|dd�|j�t�|dd�|j�dS)NcSst|���S)N)rVr7)rrrr
�<lambda>��z<OrderedDictTests.test_free_after_iterating.<locals>.<lambda>cSst|���S)N)rVrS)rrrr
r��r�cSst|���S)N)rVr*)rrrr
r��r�)rZcheck_free_after_iteratingrVr$)rrrr
�test_free_after_iterating�sz*OrderedDictTests.test_free_after_iteratingN)1r:r;r<r.r/r6r>rDrHrKrNrQrUr[r\r^rargrnrpr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
rs\.
		




		'			rc@seZdZeZejZdS)�PurePythonOrderedDictTestsN)r:r;r<�py_collrxr$rrrr
r��sr�c@seZdZdZeZeZdS)�CPythonBuiltinDictTestszaBuiltin dict preserves insertion order.

    Reuse some of tests in OrderedDict selectively.
    N)r:r;r<�__doc__�builtinsrxr)r$rrrr
r��sr�z�test_init test_update test_abc test_clear test_delitem test_setitem test_detect_deletion_during_iteration test_popitem test_reinsert test_override_update test_highly_nested test_highly_nested_subclass test_delitem_hash_collision z0requires the C version of the collections modulec@sHeZdZeZejZejZejdd��Z	dd�Z
dd�Zejdd��Zd	S)
�CPythonOrderedDictTestscCs||j}tj}tj}|j}|d�|d�}|d�}|d�}|d�}|�}	||	|dd|�d|	_||	|dd|�|	�d	d
�td�D��||	|d|dd|d|�|	�dd
�tdd
�D��||	|d|dd
|d
|�||	�	�|d��||	�
�|d��||	��|d��|d�}
|t|	�|
�|t|	�	��|
�|t|	�
��|
�|t|	���|
�dS)NZnQ2P3PnPn2PZ2nP2nZn2P�PZPn2Pr1rrcSsg|]}||f�qSrr)r@rbrrr
rA�sz=CPythonOrderedDictTests.test_sizeof_exact.<locals>.<listcomp>rcSsg|]}||f�qSrr)r@rbrrr
rA�srO�ZiP2n2P)
r$�struct�calcsizerZcalcobjsize�check_sizeofr�r4rer7r*rSrV)rr$r��sizeruZ	basicsizeZ	entrysize�pZnodesizer5Zitersizerrr
�test_sizeof_exact�s0&&z)CPythonOrderedDictTests.test_sizeof_exactc	Cs�|j}|�d�}|�t|�td��|�t��2x*t|�D]\}}|�|�|�|d�q:WWdQRX|�t��x|D]}d|d<qxWWdQRX|�t��x|D]
}|d=q�WWdQRX|�t|�td��dS)Nr�rr rZbdeaf)	r$rCr'r+r%�RuntimeError�	enumerater�Z
assertLess)rr$r5rbrkrrr
� test_key_change_during_iteration�s



z8CPythonOrderedDictTests.test_key_change_during_iterationcCs�|j}ddddddg}||�}x�dD]�}t||�}t|��dd�}xxttjd�D]f}|j||d	��Nt|��}t|�t�	||�}	t�
|	�}
|�t|
�|�|�t|�|�WdQRXqTWq$WdS)
N)rr)rr)rr)rr)rr)r r!)r7rSr*r)�method_nameZprotocol)r$�getattrr+reryrzr{rVrWr}r|r')rr$r-r5r�ZmethZexpectedrbrYr�Z	unpickledrrr
�test_iterators_pickling�s



z/CPythonOrderedDictTests.test_iterators_picklingcCsJt��|��}||_g}|�|�t�|�}|�|�~~~t��dS)N)r�r�r$�cycler8r�r�)rr�r�Zx_refrrr
�"test_weakref_list_is_not_traversed�s


z:CPythonOrderedDictTests.test_weakref_list_is_not_traversedN)
r:r;r<�c_collrxr$rr�Zcpython_onlyr�r�r�r�rrrr
r��s r�c@s"eZdZeZGdd�dej�ZdS)�"PurePythonOrderedDictSubclassTestsc@seZdZdS)z.PurePythonOrderedDictSubclassTests.OrderedDictN)r:r;r<rrrr
r$sr$N)r:r;r<r�rxr$rrrr
r�sr�c@s"eZdZeZGdd�dej�ZdS)�CPythonOrderedDictSubclassTestsc@seZdZdS)z+CPythonOrderedDictSubclassTests.OrderedDictN)r:r;r<rrrr
r$sr$N)r:r;r<r�rxr$rrrr
r�sr�c@s eZdZedd��Zdd�ZdS)�PurePythonGeneralMappingTestscCstj|_dS)N)r�r$�	type2test)�clsrrr
�
setUpClasssz(PurePythonGeneralMappingTests.setUpClasscCs|��}|�t|j�dS)N)�_empty_mappingr%rMr_)rrrrr
rasz*PurePythonGeneralMappingTests.test_popitemN)r:r;r<�classmethodr�rarrrr
r�sr�c@s eZdZedd��Zdd�ZdS)�CPythonGeneralMappingTestscCstj|_dS)N)r�r$r�)r�rrr
r�!sz%CPythonGeneralMappingTests.setUpClasscCs|��}|�t|j�dS)N)r�r%rMr_)rrrrr
ra%sz'CPythonGeneralMappingTests.test_popitemN)r:r;r<r�r�rarrrr
r�sr�c@s eZdZedd��Zdd�ZdS)�PurePythonSubclassMappingTestscCsGdd�dtj�}||_dS)Nc@seZdZdS)z@PurePythonSubclassMappingTests.setUpClass.<locals>.MyOrderedDictN)r:r;r<rrrr
�
MyOrderedDict.sr�)r�r$r�)r�r�rrr
r�,sz)PurePythonSubclassMappingTests.setUpClasscCs|��}|�t|j�dS)N)r�r%rMr_)rrrrr
ra2sz+PurePythonSubclassMappingTests.test_popitemN)r:r;r<r�r�rarrrr
r�*sr�c@s eZdZedd��Zdd�ZdS)�CPythonSubclassMappingTestscCsGdd�dtj�}||_dS)Nc@seZdZdS)z=CPythonSubclassMappingTests.setUpClass.<locals>.MyOrderedDictN)r:r;r<rrrr
r�<sr�)r�r$r�)r�r�rrr
r�:sz&CPythonSubclassMappingTests.setUpClasscCs|��}|�t|j�dS)N)r�r%rMr_)rrrrr
ra@sz(CPythonSubclassMappingTests.test_popitemN)r:r;r<r�r�rarrrr
r�7sr��__main__))r��
contextlibrwr�ryZrandomrrr�r	Zunittestr�Zcollections.abcrZtestrrZimport_fresh_moduler�r��contextmanagerrrZTestCaser�r�r��method�setattrr�Z
skipUnlessr�r�r�ZBasicTestMappingProtocolr�r�r�r�r:�mainrrrr
�<module>sJ
u	]