Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_binop.cpython-39.opt-1.pyc

a

��g�8�@sjdZddlZddlmZmZmZddlmZdd�Zdd�Z	d	d
�Z
dd�ZGd
d�de�Z
Gdd�dej�ZGdd�d�Zdd�ZGdd�de�ZGdd�deed�ZGdd�de�ZGdd�de�Ze�e�Gdd�dej�ZGd d!�d!e�ZGd"d#�d#e�ZGd$d%�d%e�ZGd&d'�d'e�ZGd(d)�d)e�ZGd*d+�d+�ZGd,d-�d-ej�Zed.k�rfe� �dS)/z9Tests for binary operators on subtypes of built-in types.�N)�eq�le�ne)�ABCMetacCs|r|||}}q|S)z1Greatest common divisor using Euclid's algorithm.�)�a�brr�+/usr/local/lib/python3.9/test/test_binop.py�gcdsr
cCs
t|t�S)z-Test whether an object is an instance of int.)�
isinstance�int��xrrr	�isint
srcCs$tttfD]}t||�r
dSq
dS)zATest whether an object is an instance of a built-in numeric type.�r)r�float�complexr)r�Trrr	�isnums
rcCs
t|t�S)z7Test whether an object is an instance of the Rat class.)r�Ratr
rrr	�isRatsrc@s�eZdZdZddgZd/dd�Zdd	�Zeed
�Zdd�Z	ee	d
�Z
d
d�Zdd�Zdd�Z
dd�Zdd�ZeZdd�Zdd�Zdd�ZeZdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd
S)0rz9Rational number implemented as a normalized pair of ints.�	_Rat__num�	_Rat__denrrcCsbt|�std|��t|�s(td|��|dkr8td��t||�}t||�|_t||�|_dS)z[Constructor: Rat([num[, den]]).

        The arguments must be ints, and default to (0, 1).zRat numerator must be int (%r)z Rat denominator must be int (%r)rzzero denominatorN)r�	TypeError�ZeroDivisionErrorr
rrr)�self�num�den�grrr	�__init__"s
zRat.__init__cCs|jS)z7Accessor function for read-only 'num' attribute of Rat.)r�rrrr	�_get_num1szRat._get_numNcCs|jS)z7Accessor function for read-only 'den' attribute of Rat.)rr rrr	�_get_den6szRat._get_dencCsd|j|jfS)z<Convert a Rat to a string resembling a Rat constructor call.zRat(%d, %d)�rrr rrr	�__repr__;szRat.__repr__cCstt|��S)z=Convert a Rat to a string resembling a decimal numeric value.)�strrr rrr	�__str__?szRat.__str__cCs|jd|jS)zConvert a Rat to a float.��?r#r rrr	�	__float__Csz
Rat.__float__cCsN|jdkr:zt|j�WSty8tdt|���Yn0tdt|���dS)z,Convert a Rat to an int; self.den must be 1.rz%s too large to convert to intzcan't convert %s to intN)rrr�
OverflowError�repr�
ValueErrorr rrr	�__int__Gs
�zRat.__int__cCsVt|�rt|�}t|�r>t|j|j|j|j|j|j�St|�rRt|�|StS)z$Add two Rats, or a Rat and a number.�rrrrrrr�NotImplemented�r�otherrrr	�__add__Qs
�zRat.__add__cCsVt|�rt|�}t|�r>t|j|j|j|j|j|j�St|�rRt|�|StS)z)Subtract two Rats, or a Rat and a number.r-r/rrr	�__sub__^s
�zRat.__sub__cCsVt|�rt|�}t|�r>t|j|j|j|j|j|j�St|�rR|t|�StS)z9Subtract two Rats, or a Rat and a number (reversed args).r-r/rrr	�__rsub__is
�zRat.__rsub__cCsTt|�r"t|j|j|j|j�St|�r<t|j||j�St|�rPt|�|StS)z)Multiply two Rats, or a Rat and a number.�rrrrrrrr.r/rrr	�__mul__tszRat.__mul__cCsTt|�r"t|j|j|j|j�St|�r<t|j|j|�St|�rPt|�|StS)z'Divide two Rats, or a Rat and a number.r4r/rrr	�__truediv__�szRat.__truediv__cCsTt|�r"t|j|j|j|j�St|�r<t||j|j�St|�rP|t|�StS)z7Divide two Rats, or a Rat and a number (reversed args).r4r/rrr	�__rtruediv__�szRat.__rtruediv__cCs2t|�rt|�}nt|�stS||}|j|jS)z.Divide two Rats, returning the floored result.)rrrr.rr�rr0rrrr	�__floordiv__�s
zRat.__floordiv__cCs||}|j|jS)z>Divide two Rats, returning the floored result (reversed args).r#r8rrr	�
__rfloordiv__�szRat.__rfloordiv__cCs6t|�rt|�}nt|�stS||}||||fS)z2Divide two Rats, returning quotient and remainder.)rrrr.r8rrr	�
__divmod__�s
zRat.__divmod__cCs(t|�rt|�}nt|�stSt||�S)zBDivide two Rats, returning quotient and remainder (reversed args).)rrrr.�divmodr/rrr	�__rdivmod__�s

zRat.__rdivmod__cCst||�dS)zTake one Rat modulo another.r�r<r/rrr	�__mod__�szRat.__mod__cCst||�dS)z,Take one Rat modulo another (reversed args).rr>r/rrr	�__rmod__�szRat.__rmod__cCsTt|�r|jdko|j|kSt|�r<|j|jko:|j|jkSt|�rPt|�|kStS)zCompare two Rats for equality.r)rrrrrrr.r/rrr	�__eq__�sz
Rat.__eq__)rr)�__name__�
__module__�__qualname__�__doc__�	__slots__rr!�propertyrr"rr$r&r(r,r1�__radd__r2r3r5�__rmul__r6r7r9r:r;r=r?r@rArrrr	rs4






		rc@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�RatTestCasez3Unit tests for Rat class and its support utilities.cCs�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�td	d�d
�|�tdd
�d�|�td	d
�d
�tdd�D]l}tdd�D]\}|�t||�dk�|�t||�dk�|�t||�dk�|�t||�dk�q�q�dS)
N�
�����r�d�������r)�assertEqualr
�range�
assertTrue)r�i�jrrr	�test_gcd�szRatTestCase.test_gcdc	Csjtdd�}|�|jd�|�|jd�tdd�}|�|jd�|�|jd�tdd�}|�|jd�|�|jd�tdd�}|�|jd�|�|jd�td�}|�|jd�|�|jd	�ztd	d
�}Wnty�Yn0|�d�dd
ddgidttf	D]f}zt|�}Wnt�y"Yn0|�d|�ztd	|�}Wnt�yTYq�0|�d|�q�dS)NrKrNrM�i�rSrR�rrz(Rat(1, 0) didn't raise ZeroDivisionError�0gyrzRat(%r) didn't raise TypeErrorz!Rat(1, %r) didn't raise TypeError)rrUrrrZfail�unittestr)rrZbadrrr	�test_constructor�s>




zRatTestCase.test_constructorcCs�|�tdd�tdd�d�|�tdd�dtdd��|�dtdd�tdd��|�dtdd�d�|�tdd�dd�dS)NrMr[rrOr'��?�rUrr rrr	�test_add�s
zRatTestCase.test_addcCs�|�tdd�tdd�tdd��|�tdd�dtdd��|�dtdd�tdd��|�tdd�dd	�|�dtdd�d	�dS)
Nr\rMrO�rKrr[r'��?rar rrr	�test_subs
"zRatTestCase.test_subcCs~|�tdd�tdd�tdd��|�tdd�dd�|�dtdd�d�|�tdd�dd�|�dtdd�d�dS)	NrMr[rOr\rKrcrdr'rar rrr	�test_mul	s
"zRatTestCase.test_mulcCs�|�tdd�tdd�tdd��|�tdd�dtdd��|�dtd�tdd��|�dtd	d�d
�|�td	d�dd
�dS)NrKr[rOr\��	rM�@rr`rar rrr	�test_divs
"zRatTestCase.test_divcCs`|�td�td�d�|�tdd�tdd�d�|�td�dd�|�dtd�d�dS)NrK�rMr[rar rrr	�
test_floordivszRatTestCase.test_floordivcCsZ|�td�tdd��|�td�d�|�dtd��|�td�d�|�dtd��dS)NrKrTrMg$@rar rrr	�test_eqs
zRatTestCase.test_eqcCs�|�tdd�tdd�tdd��|�tdd�dtdd��|�dtd�tdd��|�dtd	d�d
�|�td	d�dd
�|�td�d�dS)
NrKr[rOr\rgrhrMrirr`z1/2rd)rUr�evalr rrr	�
test_true_div$s"zRatTestCase.test_true_divN)
rBrCrDrErZr_rbrerfrjrlrmrorrrr	rJ�s$rJc@s eZdZdZdd�Zdd�ZdS)�OperationLoggerz.Base class for classes with operation logging.cCs
||_dS�N��logger)rrsrrr	r1szOperationLogger.__init__cGs|j|�dSrqrr)r�argsrrr	�
log_operation3szOperationLogger.log_operationN)rBrCrDrErrurrrr	rp/srpcGsFg}g}|D]}|�||j��qz||�Wnty@Yn0|S)zvReturn the sequence of operations that results from applying
    the operation `op` to instances of the given classes.)�appendr)�op�classes�logZ	instances�crrr	�op_sequence6sr{c@s$eZdZdd�Zdd�Zdd�ZdS)�AcCs|�d�tS)N�A.__eq__�rur.r/rrr	rAEs
r}cCs|�d�tS)N�A.__le__r~r/rrr	�__le__Hs
rcCs|�d�tS)N�A.__ge__r~r/rrr	�__ge__Ks
r�N�rBrCrDrAr�r�rrrr	r|Dsr|c@s$eZdZdd�Zdd�Zdd�ZdS)�BcCs|�d�tS)N�B.__eq__r~r/rrr	rAPs
r�cCs|�d�tS)N�B.__le__r~r/rrr	r�Ss
r�cCs|�d�tS)N�B.__ge__r~r/rrr	r�Vs
r�Nr�rrrr	r�Osr�)�	metaclassc@s$eZdZdd�Zdd�Zdd�ZdS)�CcCs|�d�tS)N�C.__eq__r~r/rrr	rA[s
r�cCs|�d�tS)N�C.__le__r~r/rrr	r�^s
r�cCs|�d�tS)N�C.__ge__r~r/rrr	r�as
r�Nr�rrrr	r�Zsr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�VzVirtual subclass of BcCs|�d�tS)N�V.__eq__r~r/rrr	rAgs
r�cCs|�d�tS)N�V.__le__r~r/rrr	r�js
r�cCs|�d�tS)N�V.__ge__r~r/rrr	r�ms
r�N)rBrCrDrErAr�r�rrrr	r�esr�c@seZdZdd�ZdS)�OperationOrderTestscCs4|�tttt�ddg�|�tttt�ddg�|�tttt�ddg�|�tttt�ddg�|�tttt�ddg�|�tttt�ddg�|�tttt�ddg�|�tttt�ddg�|�tttt�ddg�|�tttt�d	dg�|�tt	t��|�tttt	�dd
g�|�tttt	�ddg�dS)Nr}r�r�rr�r�r�r�r�r�r�)
rUr{rr|r�r�rrW�
issubclassr�r rrr	�test_comparison_orderstsz*OperationOrderTests.test_comparison_ordersN)rBrCrDr�rrrr	r�ssr�c@seZdZdZdd�ZdS)�SupEqzClass that can test equalitycCsdS�NTrr/rrr	rA�szSupEq.__eq__N�rBrCrDrErArrrr	r��sr�c@seZdZdZdZdS)�Sz"Subclass of SupEq that should failNr�rrrr	r��sr�c@seZdZdZdS)�Fz'Independent class that should fall backN)rBrCrDrErrrr	r��sr�c@seZdZdZdZdS)�Xz"Independent class that should failNr�rrrr	r��sr�c@seZdZdZdZdS)�SNz>Subclass of SupEq that can test equality, but not non-equalityN)rBrCrDrE�__ne__rrrr	r��sr�c@seZdZdZdd�ZdZdS)�XNz>Independent class that can test equality, but not non-equalitycCsdSr�rr/rrr	rA�sz	XN.__eq__N)rBrCrDrErAr�rrrr	r��sr�c@s eZdZdZdd�Zdd�ZdS)�FallbackBlockingTestsz#Unit tests for None method blockingcCs�t�t�t�t�f\}}}}|�||�|�||�|�||�|�||�|�tt||�|�tt||�|�tt||�dSrq)r�r�r�r�rU�assertRaisesrr)r�e�f�srrrr	�test_fallback_rmethod_blocking�sz4FallbackBlockingTests.test_fallback_rmethod_blockingcCsft�t�t�}}}|�||k�|�tt||�|�tt||�|�||k�|�tt||�dSrq)r�r�r�ZassertFalser�rr)rr�ZsnZxnrrr	�test_fallback_ne_blocking�sz/FallbackBlockingTests.test_fallback_ne_blockingN)rBrCrDrEr�r�rrrr	r��sr��__main__)!rEr^�operatorrrr�abcrr
rrr�objectrZTestCaserJrpr{r|r�r�r��registerr�r�r�r�r�r�r�r�rB�mainrrrr	�<module>s6*j



Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists