Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/unittest/test/testmock/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/unittest/test/testmock/__pycache__/testhelpers.cpython-38.pyc
U

@��g��@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�A/opt/cppython/lib/python3.8/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	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)Zzinga�alpha)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_orderN)rrrr)r,r.r<rrrrr sr 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)r>rr>rr"�r5r�bazZspam�����)r>rCrC)�rDrE�)r#rG)r>rGrG)r5rGr5rrF�rr$�assertNotEqual)r�kallrrr�test_call_with_callGs<zCallTest.test_call_with_callcCsjt�}|�|d�|�|d�|�|d�|�|d�|�|ddif�|�|dif�|�|if�dS)Nrr"r?�r#rr#)rr$�r�argsrrr�test_empty__CalllszCallTest.test_empty__CallcCs�tddif�}|�|d�|�|d�|�|ddif�|�|dif�|�|d�|�|d�|�|if�|�|d�|�|d�|�|dif�dS)	Nr#rr"rMr?)r5r@r5rIrNrrr�test_named_empty_callxszCallTest.test_named_empty_callcCsftdif�}|�|d�|�|d�|�|ddif�|�|dif�|�|jd�|�|ji�dS)NrCrB�r#rCr#)rr$rO�kwargsrNrrr�test_call_with_args�szCallTest.test_call_with_argscCshtddif�}|�|d�|�|ddif�|�|jd�|�|ji�|�|d�|�|dif�dS)Nr#rCrRrB)rr$rOrSrJrNrrr�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)NrrFrH�rrr#)r�dictr$rOrSrNrrr�test_call_with_kwargs�szCallTest.test_call_with_kwargsc	Cs�tddtddd�f�}|�|dtddd�f�|�|ddtddd�f�|�|jd�|�|jtddd��|�|tddd�f�|�|dtddd�f�dS)Nr#rrFrHrV)rrWr$rOrSrJrNrrr�test_named_call_with_kwargs�sz$CallTest.test_named_call_with_kwargscCsNtdif�}|�|tddd��|�tddd�|�|�tddd�|g�dS)NrCrDrErF)rr$r�assertInrNrrr�#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)NrBrDrErF�rDrE)rJrr�assertFalse�
assertTruerrrr�test_call_ne�szCallTest.test_call_necCs8td�}dd|tfD]}|�||�|�||k�qdS)NrBrD)r�intrJr])rrK�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()rCrrzcall(1, 2, 3, a='b')r5zcall.bar(1, 2, 3, a='b')rrDzcall(1)�thing)�zzzcall(zz='thing')z
call().foorF�rzcall().foo.bar().bingrEzcall().foo(1, 2, a=3)zcall()()z	call()(2)zcall()().bar().baz.beep(1))
r$r*rrr+r#r5�bingrA�beeprrrrr,�s6�����zCallTest.test_reprcCs||�t�ddif�|�tddddd�ddddd�f�t�}|d	d
d�|ddd�|�|jtd	d
d�tddd�g�dS)
Nr>rr#r5rFrH)rrr4rDrE�rV)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)
NrDr#)rDZeggs)�fishzbar.bazrrkrErFrhrV)r$rr#r5rAr�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)NrDrErFrHrez().foo().bar)rFrVrh���)
rr#r5r$rWrZ	call_argsrJrir9rArg�	call_list)r�resultr(Z	last_callrrr�test_extended_callszCallTest.test_extended_callcCs@tdd�j}tdd�j}|�||�|�||�|�||�dS�NrD��xrE)rr#r$rJrrrr�test_extended_not_equals
z CallTest.test_extended_not_equalcCsHtdd���j}tdd���j}|�||�|�||�|�||�dSrr)rr#r5r$rJrrrr�test_nested_calls_not_equals
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)NrDrErFrH�)rr$rror9r8r`r#r5rA�__int__)rr(rKrrr�test_call_list%s"��$$zCallTest.test_call_listcCs>|�tt�t�}t|�|�|jtg�|�tg|j�dSr)r$rrrr`r9�r�mrrr�
test_call_any:s
zCallTest.test_call_anycCshtdddifdd�}|�t|�d�|�|dd�|�|dddi�tdddif�}|�||�dS)	Nr\rrFT)rrErrD)rr$�len)rrOZ
other_argsrrr�test_two_args_callCszCallTest.test_two_args_callcCsJ|�tdd�dd�|�td�dd�|�tdddif�dd�dS)	Nrr#r)�r5Zbarzr>rZhelloZworld)r$rrrrr�test_call_with_nameLszCallTest.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)Nr5rD)	rr#r$r9r�__getitem__�__setitem__�iter�__iter__rzrrr�test_dunder_callQs$*���zCallTest.test_dunder_callN)rrrrLrPrQrTrUrXrYr[r_rbr,rjrmrqrurvryr|r~r�r�rrrrr=Es*%		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+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#rDrErFrHre)	�assertRaises�AttributeError�getattrrr&�AssertionError�	TypeErrorrrr'rrr�_check_someclass_mockhs6�
�
�
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)rr`r7r$rxZ
call_countrzrrr�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#rD)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>.FoorFN�rrrrrrrrr3�sr3�3re)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�rcSsdSrrrVrrrr#�rzJSpecSignatureTest.test_create_autospec_keyword_only_arguments.<locals>.foorDrErF)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)NcSsdSrrrerrrr��rz@SpecSignatureTest.test_function_as_instance_attribute.<locals>.frf)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�sr3rF)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_attributesc	szGdd�dt��G�fdd�dt�}t|�}|�d�|�t��|��W5QRX|�t��|�dd�W5QRXdS)Nc@seZdZdd�ZdS)zVSpecSignatureTest.test_spec_has_descriptor_returning_function.<locals>.CrazyDescriptorcSs|dkrdd�SdS)NcSsdSrrrsrrr�<lambda>�rzpSpecSignatureTest.test_spec_has_descriptor_returning_function.<locals>.CrazyDescriptor.__get__.<locals>.<lambda>r)rr�Ztype_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�rDrE)r%rr�r�r�)rr�r(rr�r�+test_spec_has_descriptor_returning_function�s
z=SpecSignatureTest.test_spec_has_descriptor_returning_functionc	s�G�fdd�dt����}|�t��|jW5QRX|�|�d�d�t|�}|�d�|�t��|��W5QRX|�t��|�dd�W5QRXdS)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|Srrrsrrrr��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��*rDrE)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�argrrrr5rzKSpecSignatureTest.test_builtin_functions_types.<locals>.BuiltinSubclass.barN)rrrr5�sortedr�rrrr�BuiltinSubclasssr�rFr#r5rDrE)�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�rDrErF)
rrrrrrr$rlr��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�@sr�r#)	r�rr$r�r�r`r��assertIsInstancerr�rrr�test_magic_methods?sz$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�Nsr�T)Zspec_setr#r5)rrr�r�r��setattrr�)rr��specr(rrr�
test_spec_setMs
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�[sz1SpecSignatureTest.test_descriptors.<locals>.Foo.fcSsdSrrrVrrr�g]sz1SpecSignatureTest.test_descriptors.<locals>.Foo.gN)rrr�classmethodr��staticmethodr�rrrrr3Zs
r3c@seZdZdS)z/SpecSignatureTest.test_descriptors.<locals>.BarNr�rrrr�Bar`sr�c@seZdZdS)z/SpecSignatureTest.test_descriptors.<locals>.BazNr�rrrr�Bazbsr�rDrErFrH)r%rrr��assert_called_once_withr�)rr3r�r�r�r(rrr�test_descriptorsYs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>.AcSsdSrrrrrrrorz-SpecSignatureTest.test_recursive.<locals>.A.azfoo bar bazN)rrrrr#r5rrrr�Ansr�)r%�Brr]Zcalledrr$rlrZassertIsr#r5�assertIsNot�lowerr�r�r&)rr�r(rrr�test_recursivems

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)rrtrrrr�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�sr3rwrsr#r5rrh)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>.FoorFNr�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)NrDr#g�?y�?FT)rr`r+rWr��set�float�complexrrrr�
test_builtins�s 
zSpecSignatureTest.test_builtinscCs�dd�}t|�}|�t|�|dd�|�dd�|jddd�|jddd�||_t|�}|�t|j�|�dd�|j�dd�|jjddd�dS)	NcSsdSrrrVrrrr��rz*SpecSignatureTest.test_function.<locals>.frDrEr�rVrFrH)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|dkrtd��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||SrrrVrrr�existing�szISpecSignatureTest.test_skip_attributeerrors.<locals>.RaiserClass.existingN)rrr�raiserr�r�r)r�rr�RaiserClass�sr�rDrErFcs��ddd�S)NrDrErF)r�rs��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>.FoorFcSsdSrrrrrr�__init__rz<SpecSignatureTest.test_signature_class.<locals>.Foo.__init__N)rF�rrrr�rrrrr3sr3rDrerErHrwrV)r%rr�r�r�r�r&)rr3r(rrr�test_signature_classs

z&SpecSignatureTest.test_signature_classcCsGdd�dt�}t|�dS)Nc@seZdZdS)z6SpecSignatureTest.test_class_with_no_init.<locals>.FooNr�rrrrr3sr3)r%r)rr3rrr�test_class_with_no_initsz)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)rrtr�rrrr�rzDSpecSignatureTest.test_signature_callable.<locals>.Callable.__init__cSsdSrrrrrr�__call__rzDSpecSignatureTest.test_signature_callable.<locals>.Callable.__call__N)rrrr�r�rrrr�Callablesr�rDrE�rtr�rre)r%rr�r�r�r&)rr�r(r�rrr�test_signature_callables(





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�8szJSpecSignatureTest.test_signature_noncallable.<locals>.NonCallable.__init__Nr�rrrr�NonCallable7sr�r)r%rr�r�r�)rr�r(r�rrr�test_signature_noncallable6s
z,SpecSignatureTest.test_signature_noncallablecCsDGdd�dt�}t|�}|j}|�|td��|��|j��dS)Nc@seZdZdZdS)z8SpecSignatureTest.test_create_autospec_none.<locals>.FooN)rrrr5rrrrr3Hsr3)r%rr5�assertNotIsInstancer�r#r�)rr3r(Znonerrr�test_create_autospec_noneGs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�UrzOSpecSignatureTest.test_autospec_functions_with_self_in_odd_place.<locals>.Foo.fNr�rrrrr3Tsr3�
r)r%rr�r&)rr3rrrr�.test_autospec_functions_with_self_in_odd_placeSs
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)ra)rrarrrr�bszLSpecSignatureTest.test_autospec_data_descriptor.<locals>.Descriptor.__init__NcSs|Srr)rr�r�rrrr�eszKSpecSignatureTest.test_autospec_data_descriptor.<locals>.Descriptor.__get__cSsdSrr)rr�rarrr�__set__hrzKSpecSignatureTest.test_autospec_data_descriptor.<locals>.Descriptor.__set__)N)rrrr�r�r�rrrr�
Descriptoras
r�c@seZdZdS)zCSpecSignatureTest.test_autospec_data_descriptor.<locals>.MyPropertyNr�rrrr�
MyPropertyjsr�cs2eZdZdgZedd��Z�dd��Z�d�ZdS)z<SpecSignatureTest.test_autospec_data_descriptor.<locals>.Foo�slotcSsdSrrrrrr�proppszASpecSignatureTest.test_autospec_data_descriptor.<locals>.Foo.propcSsdSrrrrrr�subpropsszDSpecSignatureTest.test_autospec_data_descriptor.<locals>.Foo.subpropr�N)rrr�	__slots__�propertyr�r��descr)r�r�rrr3ms

r3csH��|t�|ddd�|�ddd�|�ddd�|j�ddd�dS)NrDrErFrHrwrh)r�r�abcr�)Z	mock_attrrrr�check_data_descriptorzs
zNSpecSignatureTest.test_autospec_data_descriptor.<locals>.check_data_descriptor)r%r�rr�r�r�r�)rr3r#rr)r�r�rr�test_autospec_data_descriptor`s		


z/SpecSignatureTest.test_autospec_data_descriptorcCs\t�tjt���}|�|�t�t|�}|�|��|��|ddd�|�ddd�dS)NrHrwrh)	�types�
MethodType�time�ctimer�r+rr�r7)r�methZmockedrrr�'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)rr]�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>.myfuncrDrEr�)rr$�inspect�	signaturer9rr�r�)rrr(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>.foorDrErF)rrhrH)r�)	r`r$rr
rr9rr�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_namec	CsRdd�}t|�}|d�|�td�g�|�t��|�td�g�W5QRXdS)NcSsdSrrrerrrr��rz@SpecSignatureTest.test_spec_function_assert_has_calls.<locals>.frDrE)rZassert_has_callsrr�r�r�rrr�#test_spec_function_assert_has_calls�sz5SpecSignatureTest.test_spec_function_assert_has_callsc	CsFdd�}t|�}|d�|�d�|�t��|�d�W5QRXdS)NcSsdSrrrerrrr��rz?SpecSignatureTest.test_spec_function_assert_any_call.<locals>.frDrE)rZassert_any_callr�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)NcSsdSrrrerrrr��rz:SpecSignatureTest.test_spec_function_reset_mock.<locals>.fr�rDrE)rrr$r9rr7)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�rrrrrrrrrrrrrr�fsL


&
,


		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)	NrDrErFrerHrhr�rk)rr�rirrrZZassertNotIn)rr(rKZcallsrrr�!test_args_list_contains_call_list�s$



(z.TestCallList.test_args_list_contains_call_listcCsJt�}|dd�|jdd�|j��jddd�d}|�t|j�|�dS)	NrDrErFrerkZdog)�catzU[call(1, 2),
 call.foo(a=3),
 call.foo.bar(),
 call.foo.bar().baz('fish', cat='dog')])rr#r5rAr$r+r9)rr(r;rrr�test_call_list_strs
�zTestCallList.test_call_list_strcCs�tdttd�}|��}z^tj|��t�}|j|��|�	|j
t�t�g�d|_|�	|j
t�t�td�g�W5|��XdS)Nz%s.SomeClass.one)Znew_callablerF)r	rr
r��stoprrr�r&r$r9r)rr�r(r�rrr�test_propertymocks zTestCallList.test_propertymockcCs@t�}t�}|t|�_|j}|��|�|t�|�|t�dSr)rr
r�r#r�r�r�)rr{r�Zreturnedrrr�test_propertymock_returnvalue#s
z*TestCallList.test_propertymock_returnvalueN)rrrrrrrrrrrr�src@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestCallablePredicatecCs(ttttttfD]}|�t|��qdSr)r+�bytesr`r��tuplerr^r)rr�rrr�	test_type0szTestCallablePredicate.test_typecCs&Gdd�d�}|�}|�t|��dS)Nc@seZdZdd�ZdS)z>TestCallablePredicate.test_call_magic_method.<locals>.CallablecSsdSrrrrrrr�6rzGTestCallablePredicate.test_call_magic_method.<locals>.Callable.__call__N)rrrr�rrrrr�5sr�)r^r)rr�r�rrr�test_call_magic_method4sz,TestCallablePredicate.test_call_magic_methodcCs"Gdd�d�}|�t|j��dS)Nc@seZdZedd��ZdS)zATestCallablePredicate.test_staticmethod.<locals>.WithStaticMethodcSsdSrrrrrr�
staticfunc<szLTestCallablePredicate.test_staticmethod.<locals>.WithStaticMethod.staticfuncN)rrrr�r%rrrr�WithStaticMethod;sr&)r^rr%)rr&rrr�test_staticmethod:sz'TestCallablePredicate.test_staticmethodcCs"Gdd�d�}|�t|j��dS)Nc@seZdZed�ZdS)zMTestCallablePredicate.test_non_callable_staticmethod.<locals>.BadStaticMethodN)rrrr��not_callablerrrr�BadStaticMethodAsr)�r]rr()rr)rrr�test_non_callable_staticmethod@sz4TestCallablePredicate.test_non_callable_staticmethodcCs"Gdd�d�}|�t|j��dS)Nc@seZdZedd��ZdS)z?TestCallablePredicate.test_classmethod.<locals>.WithClassMethodcSsdSrr)r�rrr�	classfuncGszITestCallablePredicate.test_classmethod.<locals>.WithClassMethod.classfuncN)rrrr�r,rrrr�WithClassMethodFsr-)r^rr,)rr-rrr�test_classmethodEsz&TestCallablePredicate.test_classmethodcCs"Gdd�d�}|�t|j��dS)Nc@seZdZed�ZdS)zKTestCallablePredicate.test_non_callable_classmethod.<locals>.BadClassMethodN)rrrr�r(rrrr�BadClassMethodLsr/r*)rr/rrr�test_non_callable_classmethodKsz3TestCallablePredicate.test_non_callable_classmethodN)	rrrr#r$r'r+r.r0rrrrr .sr �__main__)r
rrZunittestZ
unittest.mockrrrrrrrr	r
rr�	functoolsrr%rZTestCaser r=r�rr r�mainrrrr�<module>s*00#G#

F1le Man4ger