Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/unittest/test/testmock/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/unittest/test/testmock/__pycache__/testhelpers.cpython-39.pyc

a

XC?hp��@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)	�	SomeClasscCsdS�N���self�a�brr�G/opt/alt/python39/lib64/python3.9/unittest/test/testmock/testhelpers.py�one�z
SomeClass.onecCsdSrr�rrrr�tworz
SomeClass.twoNcCsdSrr�rrrrr�threerzSomeClass.three)N)�__name__�
__module__�__qualname__rrrrrrrrsrc@s<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@seZdZdd�Zdd�ZdS)z9AnyTest.test_any_mock_calls_comparison_order.<locals>.FoocSsdSrr�r�otherrrr�__eq__1rz@AnyTest.test_any_mock_calls_comparison_order.<locals>.Foo.__eq__cSsdSrrr/rrr�__ne__2rz@AnyTest.test_any_mock_calls_comparison_order.<locals>.Foo.__ne__N)rrrr1r2rrrr�Foo0sr3�r#�bar)ZzingaZalpha)Za1Zz99)
rr%rr-�
reset_mock�methodrrr$�
mock_calls)rr(r3�d�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@seZdZdd�ZdS)z%AnyTest.test_any_no_spec.<locals>.FoocSsdSrrr/rrrr1Frz,AnyTest.test_any_no_spec.<locals>.Foo.__eq__N�rrrr1rrrrr3Esr3��r�assert_has_callsrrr&�assert_any_call�rr3r(rrr�test_any_no_specCszAnyTest.test_any_no_speccCsRGdd�d�}t|d�}||�d�|�ttd�g�|�td�|�td�dS)Nc@seZdZdd�ZdS)z*AnyTest.test_any_and_spec_set.<locals>.FoocSsdSrrr/rrrr1Qrz1AnyTest.test_any_and_spec_set.<locals>.Foo.__eq__Nr<rrrrr3Psr3)�specr=r>rArrr�test_any_and_spec_setNs
zAnyTest.test_any_and_spec_setN)	rrrr)r,r.r;rBrDrrrrr 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)rFrrFrr"�r5r�bazZspam��r=��)rFrKrK)�r=rL�)r#rN)rFrNrN)r5rNr5rrM�rr$�assertNotEqual)r�kallrrr�test_call_with_call\s<zCallTest.test_call_with_callcCsjt�}|�|d�|�|d�|�|d�|�|d�|�|ddif�|�|dif�|�|if�dS)Nrr"rG�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"rTrG)r5rHr5rPrUrrr�test_named_empty_call�szCallTest.test_named_empty_callcCsftdif�}|�|d�|�|d�|�|ddif�|�|dif�|�|jd�|�|ji�dS)NrKrJ�r#rKr#)rr$rV�kwargsrUrrr�test_call_with_args�szCallTest.test_call_with_argscCshtddif�}|�|d�|�|ddif�|�|jd�|�|ji�|�|d�|�|dif�dS)Nr#rKrYrJ)rr$rVrZrQrUrrr�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)NrrMrO�rrr#)r�dictr$rVrZrUrrr�test_call_with_kwargs�szCallTest.test_call_with_kwargsc	Cs�tddtddd�f�}|�|dtddd�f�|�|ddtddd�f�|�|jd�|�|jtddd��|�|tddd�f�|�|dtddd�f�dS)Nr#rrMrOr])rr^r$rVrZrQrUrrr�test_named_call_with_kwargs�sz$CallTest.test_named_call_with_kwargscCsNtdif�}|�|tddd��|�tddd�|�|�tddd�|g�dS)NrKr=rLrM)rr$r�assertInrUrrr�#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)NrJr=rLrM�r=rL)rQrr�assertFalse�
assertTruerrrr�test_call_ne�szCallTest.test_call_necCs8td�}dd|tfD]}|�||�|�||k�qdS)NrJr=)r�intrQrd)rrR�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()rKrrzcall(1, 2, 3, a='b')r5zcall.bar(1, 2, 3, a='b')rr=zcall(1)�thing)Zzzzcall(zz='thing')z
call().foorM�rzcall().foo.bar().bingrLzcall().foo(1, 2, a=3)zcall()()z	call()(2)zcall()().bar().baz.beep(1))
r$r*rrr+r#r5�bingrI�beeprrrrr,�s6�����zCallTest.test_reprcCs||�t�ddif�|�tddddd�ddddd�f�t�}|d	d
d�|ddd�|�|jtd	d
d�tddd�g�dS)
NrFrr#r5rMrO)rrr4r=rL�r])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)
Nr=r#)r=Zeggs)�fishzbar.bazrrqrLrMrnr])r$rr#r5rIr�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)Nr=rLrMrOrkz().foo().bar)rMr]rn���)
rr#r5r$r^rZ	call_argsrQror8rIrm�	call_list)r�resultr(Z	last_callrrr�test_extended_callszCallTest.test_extended_callcCs@tdd�j}tdd�j}|�||�|�||�|�||�dS�Nr=��xrL)rr#r$rQrrrr�test_extended_not_equal*s
z CallTest.test_extended_not_equalcCsHtdd���j}tdd���j}|�||�|�||�|�||�dSrx)rr#r5r$rQrrrr�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)Nr=rLrMrO�)rr$rrur8r7rgr#r5rI�__int__)rr(rRrrr�test_call_list:s"��$$zCallTest.test_call_listcCs>|�tt�t�}t|�|�|jtg�|�tg|j�dSr)r$rrrrgr8�r�mrrr�
test_call_anyOs
zCallTest.test_call_anycCshtdddifdd�}|�t|�d�|�|dd�|�|dddi�tdddif�}|�||�dS)	NrcrrMT)rrLrr=)rr$�len)rrVZ
other_argsrrr�test_two_args_callXszCallTest.test_two_args_callcCsJ|�tdd�dd�|�td�dd�|�tdddif�dd�dS)	Nrr#r)�r5ZbarzrFr�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)Nr5r=)	rr#r$r8r�__getitem__�__setitem__�iter�__iter__r�rrr�test_dunder_callfs$*���zCallTest.test_dunder_callN)rrrrSrWrXr[r\r_r`rbrfrir,rprsrwr{r|rr�r�r�r�rrrrrEZs*%		rEc@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#r=rLrMrOrk)	�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)NcSsdSrrrrrr�f�rz>SpecSignatureTest.test_create_autospec_return_value.<locals>.fr#��return_valuec@seZdZdS)z@SpecSignatureTest.test_create_autospec_return_value.<locals>.FooN�rrrrrrrr3�sr3)rr$r%)rr�r(r3rrr�!test_create_autospec_return_value�sz3SpecSignatureTest.test_create_autospec_return_valuecCs,tt�}t|�|��|�|jjd�dS)Nr)rrgr6r$r~Z
call_countr�rrr�test_autospec_reset_mock�sz*SpecSignatureTest.test_autospec_reset_mockcCs>Gdd�dt�}t�|d�}|��}|��d�|�d�dS)Nc@seZdZdd�ZdS)z;SpecSignatureTest.test_mocking_unbound_methods.<locals>.FoocSsdSrr)rr#rrrr#�rz?SpecSignatureTest.test_mocking_unbound_methods.<locals>.Foo.fooN�rrrr#rrrrr3�sr3r#r=)r%r	�startr#r&)rr3�pZmock_foorrr�test_mocking_unbound_methods�s
z.SpecSignatureTest.test_mocking_unbound_methodscCs.Gdd�dt�}t|dd�}|�|jd�dS)Nc@seZdZdZdS)zESpecSignatureTest.test_create_autospec_keyword_arguments.<locals>.FoorMN�rrrrrrrrr3�sr3�3rk)r%rr$r)rr3r�rrr�&test_create_autospec_keyword_arguments�sz8SpecSignatureTest.test_create_autospec_keyword_argumentscCsVdd�dd�}t|�}|d�|�d�|�t|dd�|ddd�|jddd�dS)N�rcSsdSrrr]rrrr#�rzJSpecSignatureTest.test_create_autospec_keyword_only_arguments.<locals>.foor=rLrM)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)NcSsdSrrrkrrrr��rz@SpecSignatureTest.test_function_as_instance_attribute.<locals>.frl)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�rrrrr3�sr3rM)r�appendr&r�r�r�r%r#)rr(r3rrr�test_spec_as_list�s
z#SpecSignatureTest.test_spec_as_listcCs6Gdd�dt�}t|�}||jfD]}|�|�q"dS)Nc@seZdZe�ZdS)z.SpecSignatureTest.test_attributes.<locals>.SubN�rrrr�attrrrrr�Sub�sr�)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@seZdZdd�ZdS)zVSpecSignatureTest.test_spec_has_descriptor_returning_function.<locals>.CrazyDescriptorcSs|durdd�SdS)NcSsdSrrryrrr�<lambda>�rzpSpecSignatureTest.test_spec_has_descriptor_returning_function.<locals>.CrazyDescriptor.__get__.<locals>.<lambda>r)rr��type_rrr�__get__�sz^SpecSignatureTest.test_spec_has_descriptor_returning_function.<locals>.CrazyDescriptor.__get__N�rrrr�rrrr�CrazyDescriptor�sr�cseZdZ��ZdS)zNSpecSignatureTest.test_spec_has_descriptor_returning_function.<locals>.MyClassN)rrr�	some_attrr�r�rr�MyClass�sr�r=rL)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)�super�__dir__r)�
CrazyClass�	__class__rrr�
szQSpecSignatureTest.test_spec_has_function_not_in_bases.<locals>.CrazyClass.__dir__cSs|dkrdd�St|��dS)Nr�cSs|Srrryrrrr�rzgSpecSignatureTest.test_spec_has_function_not_in_bases.<locals>.CrazyClass.__getattr__.<locals>.<lambda>�r�)r�itemrrr�__getattr__szUSpecSignatureTest.test_spec_has_function_not_in_bases.<locals>.CrazyClass.__getattr__)rrrr�r��
__classcell__r�r�)r�rr�sr��*r=rL)r%r�r�r0r$r�rr�)r�instr(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>.BuiltinSubclasscSsdSrr)r�argrrrr5'rzKSpecSignatureTest.test_builtin_functions_types.<locals>.BuiltinSubclass.barN)rrrr5�sortedr�rrrr�BuiltinSubclass&sr�rMr#r5r=rL)�listrr�r&r�r�r�r5r�r�r��pop�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@seZdZe�ZdS)z0SpecSignatureTest.test_method_calls.<locals>.SubNr�rrrrr�?sr�r=rLrM)
rrrrrrr$rrr��extend)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�Usr�r#)	r�rr$r�r�rgr��assertIsInstancerr�rrr�test_magic_methodsTsz$SpecSignatureTest.test_magic_methodscCs`Gdd�dt�}||�fD]@}t|dd�}|�|�|�tt|dd�|�tt|jdd�qdS)Nc@seZdZe�ZdS)z,SpecSignatureTest.test_spec_set.<locals>.SubNr�rrrrr�csr�T)Zspec_setr#r5)rrr�r�r��setattrr�)rr�rCr(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>.FoocSsdSrr)�clsrrrrrr�psz1SpecSignatureTest.test_descriptors.<locals>.Foo.fcSsdSrrr]rrr�grsz1SpecSignatureTest.test_descriptors.<locals>.Foo.gN)rrr�classmethodr��staticmethodr�rrrrr3os
r3c@seZdZdS)z/SpecSignatureTest.test_descriptors.<locals>.BarNr�rrrr�Barurr�c@seZdZdS)z/SpecSignatureTest.test_descriptors.<locals>.BazNr�rrrr�Bazwrr�r=rLrMrO)r%rrr��assert_called_once_withr�)rr3r�r�rCr(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>.AcSsdSrrrrrrr�rz-SpecSignatureTest.test_recursive.<locals>.A.azfoo bar bazN)rrrrr#r5rrrr�A�sr�)r%�BrrdZcalledrr$rrrZassertIsr#r5�assertIsNot�lowerr�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>.FoocSsdSrr)rrzrrrr�rzBSpecSignatureTest.test_spec_inheritance_for_classes.<locals>.Foo.ac@seZdZdd�ZdS)zDSpecSignatureTest.test_spec_inheritance_for_classes.<locals>.Foo.BarcSsdSrr)r�yrrrr��rzFSpecSignatureTest.test_spec_inheritance_for_classes.<locals>.Foo.Bar.fN�rrrr�rrrrr��sr�N)rrrrr%r�rrrrr3�sr3r}ryr#r5rrn)r�r�)r%rr�rr&r�r�r�r�r�r�)rr3Z
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@seZdZdZdS)z+SpecSignatureTest.test_inherit.<locals>.FoorMNr�rrrrr3�sr3r)r%r3rr�r�r�r�)rr3r(�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)Nr=r#g�?y�?FT)rrgr+r^r��set�float�complexrrrr�
test_builtins�s 
zSpecSignatureTest.test_builtinscCs�dd�}t|�}|�t|�|dd�|�dd�|jddd�|jddd�||_t|�}|�t|j�|�dd�|j�dd�|jjddd�dS)	NcSsdSrrr]rrrr��rz*SpecSignatureTest.test_function.<locals>.fr=rLr�r]rMrO)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��szCSpecSignatureTest.test_skip_attributeerrors.<locals>.Raiser.__get__)Nr�rrrr�Raiser�sr�cseZdZ��Zedd��ZdS)z@SpecSignatureTest.test_skip_attributeerrors.<locals>.RaiserClasscSs||Srrr]rrr�existingszISpecSignatureTest.test_skip_attributeerrors.<locals>.RaiserClass.existingN)rrr�raiserr�r�r)r�rr�RaiserClasssr�r=rLrMcs��ddd�S)Nr=rLrM)r�ry��srrr�rz=SpecSignatureTest.test_skip_attributeerrors.<locals>.<lambda>cs�jSr)Znonexistingrr�rrr�r)r%r$r�rr�r�r�r�r�r#r5)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>.FoorMcSsdSrrrrrr�__init__rz<SpecSignatureTest.test_signature_class.<locals>.Foo.__init__N)rM�rrrr�rrrrr3sr3r=rkrLrOr}r])r%rr�r�r�r�r&rArrr�test_signature_classs

z&SpecSignatureTest.test_signature_classcCsGdd�dt�}t|�dS)Nc@seZdZdS)z6SpecSignatureTest.test_class_with_no_init.<locals>.FooNr�rrrrr3*sr3)r%r)rr3rrr�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@seZdZdd�Zdd�ZdS)z;SpecSignatureTest.test_signature_callable.<locals>.CallablecSsdSrr)rrzr�rrrr�1rzDSpecSignatureTest.test_signature_callable.<locals>.Callable.__init__cSsdSrrrrrr�__call__2rzDSpecSignatureTest.test_signature_callable.<locals>.Callable.__call__N)rrrr�r�rrrr�Callable0sr�r=rL�rzr�rrk)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@seZdZdd�ZdS)zASpecSignatureTest.test_signature_noncallable.<locals>.NonCallablecSsdSrrrrrrr�MszJSpecSignatureTest.test_signature_noncallable.<locals>.NonCallable.__init__Nr�rrrr�NonCallableLsr�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)rrrr5rrrrr3]sr3)r%rr5�assertNotIsInstancer�r#r�)rr3r(Znonerrr�test_create_autospec_none\sz+SpecSignatureTest.test_create_autospec_nonecCsfGdd�dt�}t|�}|�d�|j�d�|jjdd�|jdd�|j�d�|jjdd�dS)Nc@seZdZdd�ZdS)zMSpecSignatureTest.test_autospec_functions_with_self_in_odd_place.<locals>.FoocSsdSrr)rrrrrr�jrzOSpecSignatureTest.test_autospec_functions_with_self_in_odd_place.<locals>.Foo.fNr�rrrrr3isr3�
r)r%rr�r&)rr3rrrr�.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)rh)rrhrrrr�wszLSpecSignatureTest.test_autospec_data_descriptor.<locals>.Descriptor.__init__NcSs|Srr)rr�r�rrrr�zszKSpecSignatureTest.test_autospec_data_descriptor.<locals>.Descriptor.__get__cSsdSrr)rr�rhrrr�__set__}rzKSpecSignatureTest.test_autospec_data_descriptor.<locals>.Descriptor.__set__)N)rrrr�r�r�rrrr�
Descriptorvs
r�c@seZdZdS)zCSpecSignatureTest.test_autospec_data_descriptor.<locals>.MyPropertyNr�rrrr�
MyPropertysr�cs2eZdZdgZedd��Z�dd��Z�d�ZdS)z<SpecSignatureTest.test_autospec_data_descriptor.<locals>.Foo�slotcSsdSrrrrrr�prop�szASpecSignatureTest.test_autospec_data_descriptor.<locals>.Foo.propcSsdSrrrrrr�subprop�szDSpecSignatureTest.test_autospec_data_descriptor.<locals>.Foo.subpropr�N)rrr�	__slots__�propertyrr�descr)r�r�rrr3�s

r3csH��|t�|ddd�|�ddd�|�ddd�|j�ddd�dS)Nr=rLrMrOr}rn)r�r�abcr�)Z	mock_attrrrr�check_data_descriptor�s
zNSpecSignatureTest.test_autospec_data_descriptor.<locals>.check_data_descriptor)r%rrrrr�r)rr3r#rr)r�r�rr�test_autospec_data_descriptorus		


z/SpecSignatureTest.test_autospec_data_descriptorcCs\t�tjt���}|�|�t�t|�}|�|��|��|ddd�|�ddd�dS)NrOr}rn)	�types�
MethodType�time�ctimer�r+rr�r6)rZmethZmockedrrr�'test_autospec_on_bound_builtin_function�sz9SpecSignatureTest.test_autospec_on_bound_builtin_functioncCs0Gdd�d�}|�}t|�}|�t|d��dS)Nc@seZdZdd�ZdS)zESpecSignatureTest.test_autospec_getattr_partial_function.<locals>.FoocSstdd�|�S)NcSs|Srr)�namerrrr��rzcSpecSignatureTest.test_autospec_getattr_partial_function.<locals>.Foo.__getattr__.<locals>.<lambda>r
)rZ	attributerrrr��szQSpecSignatureTest.test_autospec_getattr_partial_function.<locals>.Foo.__getattr__N)rrrr�rrrrr3�sr3r)rrd�hasattr)rr3�proxyZautospecrrr�&test_autospec_getattr_partial_function�sz8SpecSignatureTest.test_autospec_getattr_partial_functioncCspdd�}t|�}|dd�|ddd�|�t�|�t�|��|�|jtdd�tddd�g�|�t|d�dS)NcSsdSrrr�rrr�myfunc�rz=SpecSignatureTest.test_spec_inspect_signature.<locals>.myfuncr=rLr�)rr$�inspect�	signaturer8rr�r�)rrr(rrr�test_spec_inspect_signature�s
 z-SpecSignatureTest.test_spec_inspect_signaturecCs�dttttd�dd�}|�|dddd�d	�t|�}|dddd�|ddd�|�t�|�t�|��|�|jtdddd�tddd�g�|�t|d�|jt|dddd
d�dS)Nr�)rr�c�returncSs|||Srr)rrrrrrr#�szFSpecSignatureTest.test_spec_inspect_signature_annotations.<locals>.foor=rLrM)rrnrO)r�)	rgr$rrrr8rr�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)r�funcr(rrr�test_spec_function_no_name�sz,SpecSignatureTest.test_spec_function_no_namecCsfdd�}t|�}|d�|�td�g�|�t�� |�td�g�Wd�n1sX0YdS)NcSsdSrrrkrrrr��rz@SpecSignatureTest.test_spec_function_assert_has_calls.<locals>.fr=rL)rr?rr�r�r�rrr�#test_spec_function_assert_has_calls�sz5SpecSignatureTest.test_spec_function_assert_has_callscCsZdd�}t|�}|d�|�d�|�t��|�d�Wd�n1sL0YdS)NcSsdSrrrkrrrr��rz?SpecSignatureTest.test_spec_function_assert_any_call.<locals>.fr=rL)rr@r�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)NcSsdSrrrkrrrr��rz:SpecSignatureTest.test_spec_function_reset_mock.<locals>.fr�r=rL)rrr$r8rr6)rr��rvr(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�rrrrrrrrrrrrrr�{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)	Nr=rLrMrkrOrnr�rq)rr�rorrraZassertNotIn)rr(rRZcallsrrr�!test_args_list_contains_call_list�s$



(z.TestCallList.test_args_list_contains_call_listcCsJt�}|dd�|jdd�|j��jddd�d}|�t|j�|�dS)	Nr=rLrMrkrqZdog)�catzU[call(1, 2),
 call.foo(a=3),
 call.foo.bar(),
 call.foo.bar().baz('fish', cat='dog')])rr#r5rIr$r+r8)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_callablerM)r	rr
r�rrr�r&r$r8r�stop)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)rrrrr!r#r$rrrrr�src@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestCallablePredicatecCs(ttttttfD]}|�t|��qdSr)r+�bytesrgr��tuplerrer)rr�rrr�	test_typeEszTestCallablePredicate.test_typecCs&Gdd�d�}|�}|�t|��dS)Nc@seZdZdd�ZdS)z>TestCallablePredicate.test_call_magic_method.<locals>.CallablecSsdSrrrrrrr�KrzGTestCallablePredicate.test_call_magic_method.<locals>.Callable.__call__N)rrrr�rrrrr�Jsr�)rer)rr�r�rrr�test_call_magic_methodIsz,TestCallablePredicate.test_call_magic_methodcCs"Gdd�d�}|�t|j��dS)Nc@seZdZedd��ZdS)zATestCallablePredicate.test_staticmethod.<locals>.WithStaticMethodcSsdSrrrrrr�
staticfuncQszLTestCallablePredicate.test_staticmethod.<locals>.WithStaticMethod.staticfuncN)rrrr�r*rrrr�WithStaticMethodPsr+)rerr*)rr+rrr�test_staticmethodOsz'TestCallablePredicate.test_staticmethodcCs"Gdd�d�}|�t|j��dS)Nc@seZdZed�ZdS)zMTestCallablePredicate.test_non_callable_staticmethod.<locals>.BadStaticMethodN)rrrr��not_callablerrrr�BadStaticMethodVsr.�rdrr-)rr.rrr�test_non_callable_staticmethodUsz4TestCallablePredicate.test_non_callable_staticmethodcCs"Gdd�d�}|�t|j��dS)Nc@seZdZedd��ZdS)z?TestCallablePredicate.test_classmethod.<locals>.WithClassMethodcSsdSrr)r�rrr�	classfunc\szITestCallablePredicate.test_classmethod.<locals>.WithClassMethod.classfuncN)rrrr�r1rrrr�WithClassMethod[sr2)rerr1)rr2rrr�test_classmethodZsz&TestCallablePredicate.test_classmethodcCs"Gdd�d�}|�t|j��dS)Nc@seZdZed�ZdS)zKTestCallablePredicate.test_non_callable_classmethod.<locals>.BadClassMethodN)rrrr�r-rrrr�BadClassMethodasr4r/)rr4rrr�test_non_callable_classmethod`sz3TestCallablePredicate.test_non_callable_classmethodN)	rrrr(r)r,r0r3r5rrrrr%Csr%�__main__)rr
rZunittestZ
unittest.mockrrrrrrrr	r
rr�	functoolsrr%rZTestCaser rEr�rr%r�mainrrrr�<module>s*0E#G#