add-determinism 0.7.3

RPM buildroot helper to strip nondeterministic bits in files
Documentation
f

��_p�c@s�ddlZddlZddlZddlZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
mZddlmZddlmZGdd�de�ZGdd�dej�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�dej�Zedkr�e��dS)�N)
�call�_Call�create_autospec�	MagicMock�Mock�ANY�	_CallList�patch�PropertyMock�	_callable)�datetime��partialc@s&eZdZdd�Zdd�Zddd�ZdS)	�	SomeClasscC�dS�N���self�a�brr�;/usr/lib64/python3.10/unittest/test/testmock/testhelpers.py�one�z
SomeClass.onecCrrr�rrrr�tworz
SomeClass.twoNcCrrr�rrrrr�threerzSomeClass.threer)�__name__�
__module__�__qualname__rrrrrrrrsrc@�<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�AnyTestcCsF|�tt��t�}|t�|�t�t�}|td�|jtd�dS�N��foo)�assertEqualr�objectr�assert_called_with�r�mockrrr�test_anys

zAnyTest.test_anycCs$|�tt�d�|�tt�d�dS)Nz<ANY>)r%�reprr�strrrrr�	test_repr"szAnyTest.test_reprcCs,t�}|t��t��d�|jttd�dSr")rr�nowr'rr(rrr�test_any_and_datetime'szAnyTest.test_any_and_datetimecCs�t�}Gdd�dt�}t��|�fD]�}|��||||d�|j|||d�|�j||d�ttttd�tjtttd�t�t�jttd�g}|�||j	�|�|j	|�q$dS)Nc@�eZdZdd�Zdd�ZdS)z9AnyTest.test_any_mock_calls_comparison_order.<locals>.FoocSrrr�r�otherrrr�__eq__1rz@AnyTest.test_any_mock_calls_comparison_order.<locals>.Foo.__eq__cSrrrr1rrr�__ne__2rz@AnyTest.test_any_mock_calls_comparison_order.<locals>.Foo.__ne__N)rrrr3r4rrrr�Foo0�r5�r$�bar)ZzingaZalpha)Za1Zz99)
rr&rr.�
reset_mock�methodrrr%�
mock_calls)rr)r5Zd�expectedrrr�$test_any_mock_calls_comparison_order.s�z,AnyTest.test_any_mock_calls_comparison_ordercCsNGdd�d�}t�}||�d�|�ttd�g�|�td�|�td�dS)Nc@�eZdZdd�ZdS)z%AnyTest.test_any_no_spec.<locals>.FoocSrrrr1rrrr3Frz,AnyTest.test_any_no_spec.<locals>.Foo.__eq__N�rrrr3rrrrr5E�r5��r�assert_has_callsrrr'�assert_any_call�rr5r)rrr�test_any_no_specCszAnyTest.test_any_no_speccCsRGdd�d�}t|d�}||�d�|�ttd�g�|�td�|�td�dS)Nc@r>)z*AnyTest.test_any_and_spec_set.<locals>.FoocSrrrr1rrrr3Qrz1AnyTest.test_any_and_spec_set.<locals>.Foo.__eq__Nr?rrrrr5Pr@r5)�specrArBrErrr�test_any_and_spec_setNs
zAnyTest.test_any_and_spec_setN)	rrrr*r-r/r=rFrHrrrrr!sr!c@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+S),�CallTestcCst�}|�|t��|�|td��|�|td��|�|tif��|�|td��|�|tdif��|�|tddif��|�|td��|�|td��|�|tdif��|�|td	dif��td
�}|�|td
��|�|td��|�|tdif��|�|tddif��td
�}|�|td��|�|tddif��td�}|�|td��|�|tddif��|�|td��|�|tddif��tddif�}|�|tddddif��|�|tdddif��|�|tdddif��|�|tddif��dS)N)��r)rJrrJrr#�r8r�bazZspam��rA��)rJrOrO)�rArP�)r$rR)rJrRrR)r8rRr8rrQ�rr%�assertNotEqual)r�kallrrr�test_call_with_call\s<zCallTest.test_call_with_callcCsjt�}|�|d�|�|d�|�|d�|�|d�|�|ddif�|�|dif�|�|if�dS)Nrr#rK�r$rr$)rr%�r�argsrrr�test_empty__Call�szCallTest.test_empty__CallcCs�tddif�}|�|d�|�|d�|�|ddif�|�|dif�|�|d�|�|d�|�|if�|�|d�|�|d�|�|dif�dS)	Nr$rr#rXrK)r8rLr8rTrYrrr�test_named_empty_call�szCallTest.test_named_empty_callcCsftdif�}|�|d�|�|d�|�|ddif�|�|dif�|�|jd�|�|ji�dS)NrOrN�r$rOr$)rr%rZ�kwargsrYrrr�test_call_with_args�szCallTest.test_call_with_argscCshtddif�}|�|d�|�|ddif�|�|jd�|�|ji�|�|d�|�|dif�dS)Nr$rOr]rN)rr%rZr^rUrYrrr�test_named_call_with_args�sz"CallTest.test_named_call_with_argsc	Cs�tdtddd�f�}|�|tddd�f�|�|dtddd�f�|�|ddtddd�f�|�|dtddd�f�|�|jd�|�|jtddd��dS)NrrQrS�rrr$)r�dictr%rZr^rYrrr�test_call_with_kwargs�szCallTest.test_call_with_kwargsc	Cs�tddtddd�f�}|�|dtddd�f�|�|ddtddd�f�|�|jd�|�|jtddd��|�|tddd�f�|�|dtddd�f�dS)Nr$rrQrSra)rrbr%rZr^rUrYrrr�test_named_call_with_kwargs�sz$CallTest.test_named_call_with_kwargscCsNtdif�}|�|tddd��|�tddd�|�|�tddd�|g�dS)NrOrArPrQ)rr%r�assertInrYrrr�#test_call_with_args_call_empty_name�sz,CallTest.test_call_with_args_call_empty_namecCsR|�td�tdd��|�td�tddd�k�|�tdif�tddd�k�dS)NrNrArPrQ�rArP)rUrr�assertFalse�
assertTruerrrr�test_call_ne�szCallTest.test_call_necCs8td�}dd|tfD]}|�||�|�||k�qdS)NrNrA)r�intrUrh)rrV�valuerrr�test_call_non_tuples�szCallTest.test_call_non_tuplescCs^|�tt��d�|�ttd��d�|�ttdddif��d�|�ttddddif��d	�|�tt�d
�|�tt�d
�|�tt��d�|�ttd��d�|�ttd
d��d�|�tt�j�d�|�ttd�jjdd�j�d�|�tt�jdddd��d�|�tt���d�|�ttd�d��d�|�tt����j�	d��d�dS)Nzcall()r#z
call.foo()rOrrzcall(1, 2, 3, a='b')r8zcall.bar(1, 2, 3, a='b')rrAzcall(1)Zthing)Zzzzcall(zz='thing')z
call().foorQ�rzcall().foo.bar().bingrPzcall().foo(1, 2, a=3)zcall()()z	call()(2)zcall()().bar().baz.beep(1))
r%r+rrr,r$r8�bingrM�beeprrrrr-�s6�����zCallTest.test_reprcCs||�t�ddif�|�tddddd�ddddd�f�t�}|d	d
d�|ddd�|�|jtd	d
d�tddd�g�dS)
NrJrr$r8rQrS)rrr7rArP�ra)r%rr�call_args_listr(rrr�	test_call�s��zCallTest.test_callcCs�|�t�d�ddif�|�tjjdd�ddddif�t�}|�dd	d
�|jjd
dd�|�|jt�dd	d
�tjjd
dd�g�dS)
NrAr$)rAZeggs)�fishzbar.bazrrtrPrQrqra)r%rr$r8rMr�method_callsr(rrr�test_attribute_call
s��zCallTest.test_attribute_callc	Cstd��d�jddd�}|�|ddtdd�f�t�}|ddddd�|�|jtddddd��|�|jtddd��|�|jtddddd�g�|�|j	tddddd�g�t�}|�d����j
jd	d�t�d����j
jd	d�}|�|j	d
|�|�|j	|���dS)NrArPrQrSrnz().foo().bar�rQrarqi����)
rr$r8r%rbrZ	call_argsrUrrr;rMrp�	call_list)rZresultr)Z	last_callrrr�test_extended_callszCallTest.test_extended_callcCs@tdd�j}tdd�j}|�||�|�||�|�||�dS�NrA��xrP)rr$r%rUrrrr�test_extended_not_equal*s
z CallTest.test_extended_not_equalcCsHtdd���j}tdd���j}|�||�|�||�|�||�dSrz)rr$r8r%rUrrrr�test_nested_calls_not_equal2s
z$CallTest.test_nested_calls_not_equalcCs�t�}|d�|�td���|j�t�}|d��d�|�td��d���|j�t�}|d��d�d�|�td��d�d���|j�t�}t|d��d�d�jj�	d�d��td��d�d�jj�	d�d��
�}|�|��|j�dS)NrArPrQrS�)rr%rrxr;r:rkr$r8rM�__int__)rr)rVrrr�test_call_list:s"��$$zCallTest.test_call_listcCs>|�tt�t�}t|�|�|jtg�|�tg|j�dSr)r%rrrrkr;�r�mrrr�
test_call_anyOs
zCallTest.test_call_anycCshtdddifdd�}|�t|�d�|�|dd�|�|dddi�tdddif�}|�||�dS)	NrgrrQT)rrPrrA)rr%Zlen)rrZZ
other_argsrrr�test_two_args_callXszCallTest.test_two_args_callcCsJ|�tdd�dd�|�td�dd�|�tdddif�dd�dS)	Nrr$r)�r8ZbarzrJr�ZhelloZworld)r%rrrrr�test_call_with_nameaszCallTest.test_call_with_namec	Cs�t�}|���d�|�|jt�t���t����d�t������g�t�}d|���d<|�|jt�t���t����dd�g�t�}t|����|�|jt�t���t�����g�dS)Nr8rA)	rr$r%r;rZ__getitem__Z__setitem__ZiterZ__iter__r�rrr�test_dunder_callfs$*���zCallTest.test_dunder_callN)rrrrWr[r\r_r`rcrdrfrjrmr-rsrvryr}r~r�r�r�r�r�rrrrrIZs*%		rIc@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(dMS)N�SpecSignatureTestcCs�|�tt|d�|�dd�|j�dd�|�t|jjdd�|�t|jd�|��|j��|�t|jjd�|�t|jd�|��|j��|�t|jjd�|�t|jdd�|�d�|j�d�|jdd�|jjdd�dS)Nr$rArPrQrSrn)	�assertRaises�AttributeError�getattrrr'�AssertionError�	TypeErrorrrr(rrr�_check_someclass_mock}s.
�
�
�
z'SpecSignatureTest._check_someclass_mockcCs*tt�}|�|�tt��}|�|�dSr)rrr�r(rrr�
test_basic�s

zSpecSignatureTest.test_basiccCsPdd�}t|dd�}|�|�d�Gdd�dt�}t|dd�}|�|�d�dS)NcSrrrrrrr�f�rz>SpecSignatureTest.test_create_autospec_return_value.<locals>.fr$��return_valuec@�eZdZdS)z@SpecSignatureTest.test_create_autospec_return_value.<locals>.FooN�rrrrrrrr5�r@r5)rr%r&)rr�r)r5rrr�!test_create_autospec_return_value�sz3SpecSignatureTest.test_create_autospec_return_valuecCs,tt�}t|�|��|�|jjd�dS)Nr)rrkr9r%r�Z
call_countr�rrr�test_autospec_reset_mock�sz*SpecSignatureTest.test_autospec_reset_mockcCs>Gdd�dt�}t�|d�}|��}|��d�|�d�dS)Nc@r>)z;SpecSignatureTest.test_mocking_unbound_methods.<locals>.FoocSrrr)rr$rrrr$�rz?SpecSignatureTest.test_mocking_unbound_methods.<locals>.Foo.fooN�rrrr$rrrrr5�r@r5r$rA)r&r�startr$r')rr5�pZmock_foorrr�test_mocking_unbound_methods�s
z.SpecSignatureTest.test_mocking_unbound_methodscCs.Gdd�dt�}t|dd�}|�|jd�dS)Nc@�eZdZdZdS)zESpecSignatureTest.test_create_autospec_keyword_arguments.<locals>.FoorQN�rrrrrrrrr5�r@r5Z3rn)r&rr%r)rr5r�rrr�&test_create_autospec_keyword_arguments�sz8SpecSignatureTest.test_create_autospec_keyword_argumentscCsVdd�dd�}t|�}|d�|�d�|�t|dd�|ddd�|jddd�dS)N�rcSrrrrarrrr$�rzJSpecSignatureTest.test_create_autospec_keyword_only_arguments.<locals>.foorArPrQ)rr'r�r�)rr$r�rrr�+test_create_autospec_keyword_only_arguments�s
z=SpecSignatureTest.test_create_autospec_keyword_only_argumentscCs6t�}dd�}||_t|�}|�d�|j�d�dS)NcSrrrrnrrrr��rz@SpecSignatureTest.test_function_as_instance_attribute.<locals>.fro)rr�rr')r�objr�r)rrr�#test_function_as_instance_attribute�s
z5SpecSignatureTest.test_function_as_instance_attributecCsvtg�}|�d�|j�d�|�tt|d�Gdd�dt�}t|�}|j�d�|jj�d�|�tt|jd�dS)Nr$c@seZdZgZdS)z0SpecSignatureTest.test_spec_as_list.<locals>.FooNr�rrrrr5�r@r5rQ)r�appendr'r�r�r�r&r$)rr)r5rrr�test_spec_as_list�s
z#SpecSignatureTest.test_spec_as_listcCs6Gdd�dt�}t|�}||jfD]}|�|�q"dS)Nc@�eZdZe�ZdS)z.SpecSignatureTest.test_attributes.<locals>.SubN�rrrr�attrrrrr�Sub�r@r�)rrr�r�)rr�Zsub_mockr)rrr�test_attributes�sz!SpecSignatureTest.test_attributescs�Gdd�dt��G�fdd�dt�}t|�}|�d�|�t��|��Wd�n1s^0Y|�t��|�dd�Wd�n1s�0YdS)Nc@r>)zVSpecSignatureTest.test_spec_has_descriptor_returning_function.<locals>.CrazyDescriptorcSs|durdd�SdS)NcSrrrr{rrr�<lambda>�rzpSpecSignatureTest.test_spec_has_descriptor_returning_function.<locals>.CrazyDescriptor.__get__.<locals>.<lambda>r)rr�Ztype_rrr�__get__��z^SpecSignatureTest.test_spec_has_descriptor_returning_function.<locals>.CrazyDescriptor.__get__N�rrrr�rrrr�CrazyDescriptor��r�cseZdZ��ZdS)zNSpecSignatureTest.test_spec_has_descriptor_returning_function.<locals>.MyClassN)rrr�	some_attrr�r�rr�MyClass�r�r�rArP)r&rr�r�r�)rr�r)rr�r�+test_spec_has_descriptor_returning_function�s
&z=SpecSignatureTest.test_spec_has_descriptor_returning_functioncs�G�fdd�dt����}|�t��|jWd�n1s@0Y|�|�d�d�t|�}|�d�|�t��|��Wd�n1s�0Y|�t��|�dd�Wd�n1s�0YdS)Ncs&eZdZ��fdd�Zdd�Z�ZS)zISpecSignatureTest.test_spec_has_function_not_in_bases.<locals>.CrazyClasscst�|���dgS)N�crazy)Zsuper�__dir__r)�
CrazyClass�	__class__rrr�
�zQSpecSignatureTest.test_spec_has_function_not_in_bases.<locals>.CrazyClass.__dir__cSs|dkrdd�St|��dS)Nr�cS�|Srrr{rrrr�rzgSpecSignatureTest.test_spec_has_function_not_in_bases.<locals>.CrazyClass.__getattr__.<locals>.<lambda>�r�)rZitemrrr�__getattr__�zUSpecSignatureTest.test_spec_has_function_not_in_bases.<locals>.CrazyClass.__getattr__)rrrr�r�Z
__classcell__r�r�)r�rr�sr��*rArP)r&r�r�r2r%r�rr�)rZinstr)rr�r�#test_spec_has_function_not_in_bases	s
$
&z5SpecSignatureTest.test_spec_has_function_not_in_basescCs�Gdd�dt�}t|�}|�d�|j�d�|�tt|jd�|�d�|j�d�|�t|jdd�|�tt|jd�|�	ddg�|j	�ddg�|�tt|j	d�|j
�d�|j
j�d�|�tt|j
d�dS)Nc@seZdZdd�ZeZiZdS)zGSpecSignatureTest.test_builtin_functions_types.<locals>.BuiltinSubclasscSrrr)rZargrrrr8'rzKSpecSignatureTest.test_builtin_functions_types.<locals>.BuiltinSubclass.barN)rrrr8�sortedr�rrrr�BuiltinSubclass&�r�rQr$r8rArP)�listrr�r'r�r�r�r8r�r�r�Zpop�rr�r)rrr�test_builtin_functions_types"s

z.SpecSignatureTest.test_builtin_functions_typescCs�Gdd�dt�}t|�}|�dd�|��|�d�t�dd�t��t�d�g}|�|j|�|j�dd�|j��|j�d�|�	tj�dd�tj��tj�d�g�|�|j|�dS)Nc@r�)z0SpecSignatureTest.test_method_calls.<locals>.SubNr�rrrrr�?r@r�rArPrQ)
rrrrrrr%rur�Zextend)rr�r)r<rrr�test_method_calls>s

 �z#SpecSignatureTest.test_method_callscCs|Gdd�dt�}t|�}|�t|�g�|�tt|�|�tt|j�|�t|�g�|�|dt�|�|jdt�dS)Nc@seZdZiZdS)z=SpecSignatureTest.test_magic_methods.<locals>.BuiltinSubclassN)rrrr�rrrrr�Ur@r�r$)	r�rr%r�r�rkr��assertIsInstancerr�rrr�test_magic_methodsTsz$SpecSignatureTest.test_magic_methodscCs`Gdd�dt�}||�fD]@}t|dd�}|�|�|�tt|dd�|�tt|jdd�qdS)Nc@r�)z,SpecSignatureTest.test_spec_set.<locals>.SubNr�rrrrr�cr@r�T)Zspec_setr$r8)rrr�r�r�Zsetattrr�)rr�rGr)rrr�
test_spec_setbs
zSpecSignatureTest.test_spec_setcCs�Gdd�dt�}Gdd�d|�}Gdd�dt|�}||�||�||�fD]@}t|�}|�dd�|j�dd�|�d	d
�|j�d	d
�qHdS)Nc@s$eZdZedd��Zedd��ZdS)z/SpecSignatureTest.test_descriptors.<locals>.FoocSrrr)�clsrrrrrr�pr�z1SpecSignatureTest.test_descriptors.<locals>.Foo.fcSrrrrarrr�grr�z1SpecSignatureTest.test_descriptors.<locals>.Foo.gN)rrr�classmethodr��staticmethodr�rrrrr5os
r5c@r�)z/SpecSignatureTest.test_descriptors.<locals>.BarNr�rrrr�Barurr�c@r�)z/SpecSignatureTest.test_descriptors.<locals>.BazNr�rrrr�Bazwrr�rArPrQrS)r&rrr��assert_called_once_withr�)rr5r�r�rGr)rrr�test_descriptorsnsz"SpecSignatureTest.test_descriptorscCs�Gdd�dt�}||_t|�}|�|�|jj�|��|j��|�|jt��tj��g�|�	|j
|j�|�|j
|j�|j
�
�|�t|jj
j�dS)Nc@seZdZdd�ZdZeZdS)z+SpecSignatureTest.test_recursive.<locals>.AcSrrrrrrrr�rz-SpecSignatureTest.test_recursive.<locals>.A.azfoo bar bazN)rrrrr$r8rrrr�A�r�r�)r&ZBrrhZcalledrr%rurZassertIsr$r8�assertIsNotZlowerr�r�r')rr�r)rrr�test_recursive�s

z SpecSignatureTest.test_recursivecCs^Gdd�dt�}t|�}|�||��||�fD]L}|jdd�|jjdd�|j�d�|�t|jdd�|�tt|d�q0t|��}|�d�|j�d�|jjdd�|�t|jdd�|�tt|d�|�t|�|j	�
d�|j	j
�d�|j	j
jdd	�|�tt|j	d
�|�	��
d�|�	�j
�d�|�	�j
jdd	�|�tt|�	�d
�dS)Nc@s$eZdZdd�ZGdd�de�ZdS)z@SpecSignatureTest.test_spec_inheritance_for_classes.<locals>.FoocSrrr)rr|rrrr�rzBSpecSignatureTest.test_spec_inheritance_for_classes.<locals>.Foo.ac@r>)zDSpecSignatureTest.test_spec_inheritance_for_classes.<locals>.Foo.BarcSrrr)r�yrrrr��rzFSpecSignatureTest.test_spec_inheritance_for_classes.<locals>.Foo.Bar.fN�rrrr�rrrrr��r@r�N)rrrrr&r�rrrrr5�r6r5rr{r$r8rrq)r�r�)r&rr�rr'r�r�r�r�r�r�)rr5Z
class_mockZ	this_mockZ
instance_mockrrr�!test_spec_inheritance_for_classes�s0

z3SpecSignatureTest.test_spec_inheritance_for_classescCs�Gdd�dt�}||_t|�}|�}|�tt|d�|��}|�tt|d�t|��}|�tt|d�|�t|�|��}|�tt|d�dS)Nc@r�)z+SpecSignatureTest.test_inherit.<locals>.FoorQNr�rrrrr5�r@r5r)r&r5rr�r�r�r�)rr5r)�instanceZ
attr_instanceZcall_resultrrr�test_inherit�s
zSpecSignatureTest.test_inheritcCs�td�tt�td�tt�ti�tt�tg�tt�tt��tt�td�tt�td�tt�td�td�dS)NrAr$g�?y�?FT)rrkr,rbr�ZsetZfloatZcomplexrrrr�
test_builtins�s 
zSpecSignatureTest.test_builtinscCs�dd�}t|�}|�t|�|dd�|�dd�|jddd�|jddd�||_t|�}|�t|j�|�dd�|j�dd�|jjddd�dS)	NcSrrrrarrrr��rz*SpecSignatureTest.test_function.<locals>.frArPr�rarQrS)rr�r�r'r��rr�r)rrr�
test_function�s
zSpecSignatureTest.test_functioncs�Gdd�dt��G�fdd�dt�}|�|�dd�d�t|��|�t�fdd	��|���dd��jj�|�t�fd
d	���j}|j	|j
fdS)Nc@seZdZddd�ZdS)z;SpecSignatureTest.test_skip_attributeerrors.<locals>.RaiserNcSs|durtd��dS)Nz$Can only be accessed via an instancer�)rr��typerrrr��r�zCSpecSignatureTest.test_skip_attributeerrors.<locals>.Raiser.__get__rr�rrrr�Raiser�r@r�cseZdZ��Zedd��ZdS)z@SpecSignatureTest.test_skip_attributeerrors.<locals>.RaiserClasscSs||Srrrarrr�existingszISpecSignatureTest.test_skip_attributeerrors.<locals>.RaiserClass.existingN)rrr�raiserr�r�r)r�rr�RaiserClasssr�rArPrQcs��ddd�S)NrArPrQ)r�r{��srrr�rz=SpecSignatureTest.test_skip_attributeerrors.<locals>.<lambda>cs�jSr)Znonexistingrr�rrr�r)r&r%r�rr�r�r�r�r�r$r8)rr�r�r)r�r�r�test_skip_attributeerrors�sz+SpecSignatureTest.test_skip_attributeerrorscCs�Gdd�dt�}t|�}|�t|�|d�|�d�|jdd�|�t|jd�|dd�|�dd�|jddd�|jt|jddd�dS)	Nc@seZdZddd�ZdS)z3SpecSignatureTest.test_signature_class.<locals>.FoorQcSrrrrrrr�__init__rz<SpecSignatureTest.test_signature_class.<locals>.Foo.__init__Nrw�rrrr�rrrrr5r@r5rArnrPrSrra)r&rr�r�r�r�r'rErrr�test_signature_classs

z&SpecSignatureTest.test_signature_classcCsGdd�dt�}t|�dS)Nc@r�)z6SpecSignatureTest.test_class_with_no_init.<locals>.FooNr�rrrrr5*r@r5)r&r)rr5rrr�test_class_with_no_init'sz)SpecSignatureTest.test_class_with_no_initcCs�Gdd�dt�}t|�}|dd�|�dd�|jddd�|�t|d�|dd�}|�t|�|dd�|�d�|jdd�|d�|�d�|jdd�t|dd��}|dd�|jdd�|�t|�|d�|�d�dS)Nc@r0)z;SpecSignatureTest.test_signature_callable.<locals>.CallablecSrrr)rr|r�rrrr�1rzDSpecSignatureTest.test_signature_callable.<locals>.Callable.__init__cSrrrrrrr�__call__2rzDSpecSignatureTest.test_signature_callable.<locals>.Callable.__call__N)rrrr�r�rrrr�Callable0r6r�rArP�r|r�rrn)r&rr�r�r�r')rr�r)r�rrr�test_signature_callable/s(





z)SpecSignatureTest.test_signature_callablecCsvGdd�dt�}t|�}|�}|��|�t|d�|�t|�|�t|d�t|��}|�t|�|�t|d�dS)Nc@r>)zASpecSignatureTest.test_signature_noncallable.<locals>.NonCallablecSrrrrrrrr�Mr�zJSpecSignatureTest.test_signature_noncallable.<locals>.NonCallable.__init__Nr�rrrr�NonCallableLr@r�r)r&rr�r�r�)rr�r)r�rrr�test_signature_noncallableKs
z,SpecSignatureTest.test_signature_noncallablecCsDGdd�dt�}t|�}|j}|�|td��|��|j��dS)Nc@seZdZdZdS)z8SpecSignatureTest.test_create_autospec_none.<locals>.FooN)rrrr8rrrrr5]r@r5)r&rr8�assertNotIsInstancer�r$r�)rr5r)Znonerrr�test_create_autospec_none\sz+SpecSignatureTest.test_create_autospec_nonecCsfGdd�dt�}t|�}|�d�|j�d�|jjdd�|jdd�|j�d�|jjdd�dS)Nc@r>)zMSpecSignatureTest.test_autospec_functions_with_self_in_odd_place.<locals>.FoocSrrr)rrrrrr�jrzOSpecSignatureTest.test_autospec_functions_with_self_in_odd_place.<locals>.Foo.fNr�rrrrr5ir@r5�
r)r&rr�r')rr5rrrr�.test_autospec_functions_with_self_in_odd_placehs
z@SpecSignatureTest.test_autospec_functions_with_self_in_odd_placecsvGdd�dt��Gdd�dt��G��fdd�dt�}t|�}�fdd�}||j�||j�||j�||j�dS)	Nc@s&eZdZdd�Zddd�Zdd�ZdS)	zCSpecSignatureTest.test_autospec_data_descriptor.<locals>.DescriptorcSs
||_dSr)rl)rrlrrrr�wr�zLSpecSignatureTest.test_autospec_data_descriptor.<locals>.Descriptor.__init__NcSr�rr)rr�r�rrrr�zr�zKSpecSignatureTest.test_autospec_data_descriptor.<locals>.Descriptor.__get__cSrrr)rr�rlrrr�__set__}rzKSpecSignatureTest.test_autospec_data_descriptor.<locals>.Descriptor.__set__r)rrrr�r�r�rrrr�
Descriptorvs
r�c@r�)zCSpecSignatureTest.test_autospec_data_descriptor.<locals>.MyPropertyNr�rrrr�
MyPropertyr@r�cs2eZdZdgZedd��Z�dd��Z�d�ZdS)z<SpecSignatureTest.test_autospec_data_descriptor.<locals>.Foo�slotcSrrrrrrr�prop�r�zASpecSignatureTest.test_autospec_data_descriptor.<locals>.Foo.propcSrrrrrrr�subprop�r�zDSpecSignatureTest.test_autospec_data_descriptor.<locals>.Foo.subpropr�N)rrrZ	__slots__�propertyr�r��descr)r�r�rrr5�s

r5csH��|t�|ddd�|�ddd�|�ddd�|j�ddd�dS)NrArPrQrSrrq)r�rZabcr�)Z	mock_attrrrr�check_data_descriptor�s
zNSpecSignatureTest.test_autospec_data_descriptor.<locals>.check_data_descriptor)r&r�rr�r�r�r�)rr5r$r�r)r�r�rr�test_autospec_data_descriptorus		


z/SpecSignatureTest.test_autospec_data_descriptorcCs\t�tjt���}|�|�t�t|�}|�|��|��|ddd�|�ddd�dS)NrSrrq)	�typesZ
MethodType�timeZctimer�r,rr�r9)rZmethZmockedrrr�'test_autospec_on_bound_builtin_function�sz9SpecSignatureTest.test_autospec_on_bound_builtin_functioncCs0Gdd�d�}|�}t|�}|�t|d��dS)Nc@r>)zESpecSignatureTest.test_autospec_getattr_partial_function.<locals>.FoocSstdd�|�S)NcSr�rr)Znamerrrr��rzcSpecSignatureTest.test_autospec_getattr_partial_function.<locals>.Foo.__getattr__.<locals>.<lambda>r)rZ	attributerrrr��r�zQSpecSignatureTest.test_autospec_getattr_partial_function.<locals>.Foo.__getattr__N)rrrr�rrrrr5�r�r5r)rrhZhasattr)rr5ZproxyZautospecrrr�&test_autospec_getattr_partial_function�sz8SpecSignatureTest.test_autospec_getattr_partial_functioncCspdd�}t|�}|dd�|ddd�|�t�|�t�|��|�|jtdd�tddd�g�|�t|d�dS)NcSrrrr�rrr�myfunc�rz=SpecSignatureTest.test_spec_inspect_signature.<locals>.myfuncrArPr�)rr%�inspect�	signaturer;rr�r�)rrr)rrr�test_spec_inspect_signature�s
 z-SpecSignatureTest.test_spec_inspect_signaturecCs�dddddd�dd�}|�|dddd	�d
�t|�}|dddd	�|ddd	�|�t�|�t�|��|�|jtdddd	�tddd	�g�|�t|d�|jt|ddddd	�dS)
Nr�rk)rr�cZreturncSs|||Srr)rrrrrrr$�r�zFSpecSignatureTest.test_spec_inspect_signature_annotations.<locals>.foorArPrQ)rrqrS)r�)r%rrrr;rr�r�)rr$r)rrr�'test_spec_inspect_signature_annotations�s$z9SpecSignatureTest.test_spec_inspect_signature_annotationscCs"dd�}t|�}|�|jd�dS)NcSsdS)NZnoperrrrrr��rz>SpecSignatureTest.test_spec_function_no_name.<locals>.<lambda>Zfuncopy)rr%r)rZfuncr)rrr�test_spec_function_no_name�r�z,SpecSignatureTest.test_spec_function_no_namecCsfdd�}t|�}|d�|�td�g�|�t�� |�td�g�Wd�n1sX0YdS)NcSrrrrnrrrr��rz@SpecSignatureTest.test_spec_function_assert_has_calls.<locals>.frArP)rrCrr�r�r�rrr�#test_spec_function_assert_has_calls�sz5SpecSignatureTest.test_spec_function_assert_has_callscCsZdd�}t|�}|d�|�d�|�t��|�d�Wd�n1sL0YdS)NcSrrrrnrrrr��rz?SpecSignatureTest.test_spec_function_assert_any_call.<locals>.frArP)rrDr�r�r�rrr�"test_spec_function_assert_any_call�s
z4SpecSignatureTest.test_spec_function_assert_any_callcCsvdd�}t�}t||d�}|d�d�|�|jtd�g�|�|jtd�g�|��|�|jg�|�|jg�dS)NcSrrrrnrrrr��rz:SpecSignatureTest.test_spec_function_reset_mock.<locals>.fr�rArP)rrr%r;rr9)rr�Zrvr)rrr�test_spec_function_reset_mock�sz/SpecSignatureTest.test_spec_function_reset_mockN))rrrr�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�rrrrrr	r
rrrrr�{sL


&
,


		r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestCallListcCst�}|�|jt�|dd�|dd�|dd�|dd�tdd�tdd�tdd�tdd�fD]}|�||j�q`tdd�tdd�g}|�||j�tdd�tdd�g}|�||j�tdd�tdd�g}|�||j�tdd�g}|�||j�|�td�|j�|�td�g|j�dS)	NrArPrQrnrSrqr�rt)rr�rrrrreZassertNotIn)rr)rVZcallsrrr�!test_args_list_contains_call_list�s$



(z.TestCallList.test_args_list_contains_call_listcCsJt�}|dd�|jdd�|j��jddd�d}|�t|j�|�dS)	NrArPrQrnrtZdog)ZcatzU[call(1, 2),
 call.foo(a=3),
 call.foo.bar(),
 call.foo.bar().baz('fish', cat='dog')])rr$r8rMr%r,r;)rr)r<rrr�test_call_list_strs
�zTestCallList.test_call_list_strcCs�tdttd�}|��}zftj|��t�}|j|��|�|j	t
�t
�g�d|_|�|j	t
�t
�t
d�g�W|��n
|��0dS)Nz%s.SomeClass.one)Znew_callablerQ)rrr	r�rrr�r'r%r;rZstop)rr�r)r�rrr�test_propertymock&szTestCallList.test_propertymockcCs@t�}t�}|t|�_|j}|��|�|t�|�|t�dSr)rr	r�r$r�r�r�)rr�r�Zreturnedrrr�test_propertymock_returnvalue8s
z*TestCallList.test_propertymock_returnvalueN)rrrrr
rrrrrrr�src@r )�TestCallablePredicatecCs(ttttttfD]}|�t|��qdSr)r,Zbytesrkr�Ztuplerrir
)rr�rrr�	test_typeEszTestCallablePredicate.test_typecCs&Gdd�d�}|�}|�t|��dS)Nc@r>)z>TestCallablePredicate.test_call_magic_method.<locals>.CallablecSrrrrrrrr�KrzGTestCallablePredicate.test_call_magic_method.<locals>.Callable.__call__N)rrrr�rrrrr�Jr@r�)rir
)rr�r�rrr�test_call_magic_methodIsz,TestCallablePredicate.test_call_magic_methodcC�"Gdd�d�}|�t|j��dS)Nc@�eZdZedd��ZdS)zATestCallablePredicate.test_staticmethod.<locals>.WithStaticMethodcSrrrrrrr�
staticfuncQr�zLTestCallablePredicate.test_staticmethod.<locals>.WithStaticMethod.staticfuncN)rrrr�rrrrr�WithStaticMethodP�r)rir
r)rrrrr�test_staticmethodO�z'TestCallablePredicate.test_staticmethodcCr)Nc@�eZdZed�ZdS)zMTestCallablePredicate.test_non_callable_staticmethod.<locals>.BadStaticMethodN)rrrr��not_callablerrrr�BadStaticMethodVr@r�rhr
r)rrrrr�test_non_callable_staticmethodU�z4TestCallablePredicate.test_non_callable_staticmethodcCr)Nc@r)z?TestCallablePredicate.test_classmethod.<locals>.WithClassMethodcSrrr)r�rrr�	classfunc\r�zITestCallablePredicate.test_classmethod.<locals>.WithClassMethod.classfuncN)rrrr�r rrrr�WithClassMethod[rr!)rir
r )rr!rrr�test_classmethodZrz&TestCallablePredicate.test_classmethodcCr)Nc@r)zKTestCallablePredicate.test_non_callable_classmethod.<locals>.BadClassMethodN)rrrr�rrrrr�BadClassMethodar@r#r)rr#rrr�test_non_callable_classmethod`rz3TestCallablePredicate.test_non_callable_classmethodN)	rrrrrrrr"r$rrrrrCsrZ__main__)rr�r�ZunittestZ
unittest.mockrrrrrrrrr	r
rZ	functoolsr
r&rZTestCaser!rIr�rrrZmainrrrrZ<module>s*0E#G#