403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.153
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_binop.cpython-36.pyc
3

�w2_�8�@svdZddlZddlmZddlmZmZmZddlm	Z	dd�Z
dd	�Zd
d�Zdd
�Z
Gdd�de�ZGdd�dej�ZGdd�d�Zdd�ZGdd�de�ZGdd�dee	d�ZGdd�de�ZGdd�de�Zeje�Gdd �d ej�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�Z e!d/k�rrej"�dS)0z9Tests for binary operators on subtypes of built-in types.�N)�support)�eq�le�ne)�ABCMetacCsx|r|||}}qW|S)z1Greatest common divisor using Euclid's algorithm.�)�a�brr�4/opt/alt/python36/lib64/python3.6/test/test_binop.py�gcdsrcCs
t|t�S)z-Test whether an object is an instance of int.)�
isinstance�int)�xrrr
�isintsrcCs&x tttfD]}t||�rdSqWdS)zATest whether an object is an instance of a built-in numeric type.�r)r
�float�complexr)r�Trrr
�isnums
rcCs
t|t�S)z6Test wheter an object is an instance of the Rat class.)r�Rat)rrrr
�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�ZeroDivisionErrorrr
rr)�self�num�den�grrr
�__init__#s
zRat.__init__cCs|jS)z7Accessor function for read-only 'num' attribute of Rat.)r)rrrr
�_get_num2szRat._get_numNcCs|jS)z7Accessor function for read-only 'den' attribute of Rat.)r)rrrr
�_get_den7szRat._get_dencCsd|j|jfS)z<Convert a Rat to a string resembling a Rat constructor call.zRat(%d, %d))rr)rrrr
�__repr__<szRat.__repr__cCstt|��S)z=Convert a Rat to a string resembling a decimal numeric value.)�strr)rrrr
�__str__@szRat.__str__cCs|jd|jS)zConvert a Rat to a float.g�?)rr)rrrr
�	__float__Dsz
Rat.__float__cCsN|jdkr:y
t|j�Stk
r8tdt|���YnXtdt|���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�
ValueError)rrrr
�__int__Hs

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__Rs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.)rrrrrrrr*)rr+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).)rrrrrrrr*)rr+rrr
�__rsub__js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*)rr+rrr
�__mul__us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.)rrrrrrrr*)rr+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).)rrrrrrrr*)rr+rrr
�__rtruediv__�szRat.__rtruediv__cCs2t|�rt|�}nt|�stS||}|j|jS)z.Divide two Rats, returning the floored result.)rrrr*rr)rr+rrrr
�__floordiv__�s
zRat.__floordiv__cCs||}|j|jS)z>Divide two Rats, returning the floored result (reversed args).)rr)rr+rrrr
�
__rfloordiv__�szRat.__rfloordiv__cCs6t|�rt|�}nt|�stS||}||||fS)z2Divide two Rats, returning quotient and remainder.)rrrr*)rr+rrrr
�
__divmod__�s
zRat.__divmod__cCs(t|�rt|�}nt|�stSt||�S)zBDivide two Rats, returning quotient and remainder (reversed args).)rrrr*�divmod)rr+rrr
�__rdivmod__�s

zRat.__rdivmod__cCst||�dS)zTake one Rat modulo another.r)r5)rr+rrr
�__mod__�szRat.__mod__cCst||�dS)z,Take one Rat modulo another (reversed args).r)r5)rr+rrr
�__rmod__�szRat.__rmod__cCsTt|�r|jdko|j|kSt|�r<|j|jko:|j|jkSt|�rPt|�|kStS)zCompare two Rats for equality.r)rrrrrrr*)rr+rrr
�__eq__�sz
Rat.__eq__)rr)�__name__�
__module__�__qualname__�__doc__�	__slots__rr �propertyrr!rr"r$r%r)r,�__radd__r-r.r/�__rmul__r0r1r2r3r4r6r7r8r9rrrr
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|jtdd�d�|jtdd�d�|jtdd�d�|jtdd�d�|jtdd�d�|jtdd
�d�|jtdd�d�x~tdd	�D]p}xjtdd	�D]\}|jt||�d
k�|jt||�d
k�|jt||�d
k�|jt||�d
k�q�Wq�WdS)N�
�����r�d�ri�������rKi����rKrK)�assertEqualr�range�
assertTrue)r�i�jrrr
�test_gcd�szRatTestCase.test_gcdcCsvtdd�}|j|jd�|j|jd�tdd�}|j|jd�|j|jd�tdd�}|j|jd�|j|jd�tdd�}|j|jd�|j|jd�td�}|j|jd�|j|jd�ytdd�}Wntk
r�YnX|jd�x�d	d
dfgidttf	D]l}yt|�}Wntk
�r(YnX|jd|�ytd|�}Wntk
�r\YnX|jd
|��qWdS)NrCrFrE��rrz(Rat(1, 0) didn't raise ZeroDivisionError�0gyzRat(%r) didn't raise TypeErrorz!Rat(1, %r) didn't raise TypeErrori�rKi����rKi����i�)rrLrrrZfail�unittestr)rrZbadrrr
�test_constructor�s>




zRatTestCase.test_constructorcCs�|jtdd�tdd�d�|jtdd�dtdd��|jdtdd�tdd��|jdtdd�d�|jtdd�dd�dS)NrErRrrGg�?g�?)rLr)rrrr
�test_add�s
zRatTestCase.test_addcCs�|jtdd�tdd�tdd��|jtdd�dtdd��|jdtdd�tdd��|jtdd�dd	�|jdtdd�d	�dS)
NrSrErG�rCrrRg�?g�?)rLr)rrrr
�test_subs
"zRatTestCase.test_subcCs~|jtdd�tdd�tdd��|jtdd�dd�|jdtdd�d�|jtdd�dd�|jdtdd�d�dS)	NrErRrGrSrCrXg�?g�?)rLr)rrrr
�test_mul
s
"zRatTestCase.test_mulcCs�|jtdd�tdd�tdd��|jtdd�dtdd��|jdtd�tdd��|jdtd	d�d
�|jtd	d�dd
�dS)NrCrRrGrS��	rEg@rg�?)rLr)rrrr
�test_divs
"zRatTestCase.test_divcCs`|jtd�td�d�|jtdd�tdd�d�|jtd�dd�|jdtd�d�dS)NrC�rErR)rLr)rrrr
�
test_floordivszRatTestCase.test_floordivcCsZ|jtd�tdd��|jtd�d�|jdtd��|jtd�d�|jdtd��dS)NrCrJrEg$@)rLr)rrrr
�test_eqs
zRatTestCase.test_eqcCs�|jtdd�tdd�tdd��|jtdd�dtdd��|jdtd�tdd��|jdtd	d�d
�|jtd	d�dd
�|jtd�d�dS)
NrCrRrGrSr[r\rEg@rg�?z1/2g�?)rLr�eval)rrrr
�
test_true_div%s"zRatTestCase.test_true_divN)
r:r;r<r=rQrVrWrYrZr]r_r`rbrrrr
rB�s$rBc@s eZdZdZdd�Zdd�ZdS)�OperationLoggerz.Base class for classes with operation logging.cCs
||_dS)N)�logger)rrdrrr
r2szOperationLogger.__init__cGs|j|�dS)N)rd)r�argsrrr
�
log_operation4szOperationLogger.log_operationN)r:r;r<r=rrfrrrr
rc0srccGsLg}g}x|D]}|j||j��qWy||�Wntk
rFYnX|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_sequence7s
rlc@s$eZdZdd�Zdd�Zdd�ZdS)�AcCs|jd�tS)NzA.__eq__)rfr*)rr+rrr
r9Fs
zA.__eq__cCs|jd�tS)NzA.__le__)rfr*)rr+rrr
�__le__Is
zA.__le__cCs|jd�tS)NzA.__ge__)rfr*)rr+rrr
�__ge__Ls
zA.__ge__N)r:r;r<r9rnrorrrr
rmEsrmc@s$eZdZdd�Zdd�Zdd�ZdS)�BcCs|jd�tS)NzB.__eq__)rfr*)rr+rrr
r9Qs
zB.__eq__cCs|jd�tS)NzB.__le__)rfr*)rr+rrr
rnTs
zB.__le__cCs|jd�tS)NzB.__ge__)rfr*)rr+rrr
roWs
zB.__ge__N)r:r;r<r9rnrorrrr
rpPsrp)�	metaclassc@s$eZdZdd�Zdd�Zdd�ZdS)�CcCs|jd�tS)NzC.__eq__)rfr*)rr+rrr
r9\s
zC.__eq__cCs|jd�tS)NzC.__le__)rfr*)rr+rrr
rn_s
zC.__le__cCs|jd�tS)NzC.__ge__)rfr*)rr+rrr
robs
zC.__ge__N)r:r;r<r9rnrorrrr
rr[srrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�VzVirtual subclass of BcCs|jd�tS)NzV.__eq__)rfr*)rr+rrr
r9hs
zV.__eq__cCs|jd�tS)NzV.__le__)rfr*)rr+rrr
rnks
zV.__le__cCs|jd�tS)NzV.__ge__)rfr*)rr+rrr
rons
zV.__ge__N)r:r;r<r=r9rnrorrrr
rsfsrsc@seZdZdd�ZdS)�OperationOrderTestscCs4|jtttt�ddg�|jtttt�ddg�|jtttt�ddg�|jtttt�ddg�|jtttt�ddg�|jtttt�ddg�|jtttt�ddg�|jtttt�ddg�|jtttt�ddg�|jtttt�d	dg�|jtt	t��|jtttt	�dd
g�|jtttt	�ddg�dS)NzA.__eq__zB.__eq__zC.__eq__zA.__le__zA.__ge__zB.__ge__zB.__le__zC.__ge__zC.__le__zV.__eq__zV.__ge__)
rLrlrrmrprrrrN�
issubclassrs)rrrr
�test_comparison_ordersusz*OperationOrderTests.test_comparison_ordersN)r:r;r<rvrrrr
rttsrtc@seZdZdZdd�ZdS)�SupEqzClass that can test equalitycCsdS)NTr)rr+rrr
r9�szSupEq.__eq__N)r:r;r<r=r9rrrr
rw�srwc@seZdZdZdZdS)�Sz"Subclass of SupEq that should failN)r:r;r<r=r9rrrr
rx�srxc@seZdZdZdS)�Fz'Independent class that should fall backN)r:r;r<r=rrrr
ry�sryc@seZdZdZdZdS)�Xz"Independent class that should failN)r:r;r<r=r9rrrr
rz�srzc@seZdZdZdZdS)�SNz>Subclass of SupEq that can test equality, but not non-equalityN)r:r;r<r=�__ne__rrrr
r{�sr{c@seZdZdZdd�ZdZdS)�XNz>Independent class that can test equality, but not non-equalitycCsdS)NTr)rr+rrr
r9�sz	XN.__eq__N)r:r;r<r=r9r|rrrr
r}�sr}c@s eZdZdZdd�Zdd�ZdS)�FallbackBlockingTestsz#Unit tests for None method blockingcCs�t�t�t�t�f\}}}}|j||�|j||�|j||�|j||�|jtt||�|jtt||�|jtt||�dS)N)rwryrxrzrL�assertRaisesrr)r�e�f�srrrr
�test_fallback_rmethod_blocking�sz4FallbackBlockingTests.test_fallback_rmethod_blockingcCsft�t�t�}}}|j||k�|jtt||�|jtt||�|j||k�|jtt||�dS)N)rwr{r}ZassertFalserrr)rr�ZsnZxnrrr
�test_fallback_ne_blocking�sz/FallbackBlockingTests.test_fallback_ne_blockingN)r:r;r<r=r�r�rrrr
r~�sr~�__main__)#r=rUZtestr�operatorrrr�abcrrrrr�objectrZTestCaserBrcrlrmrprrrs�registerrtrwrxryrzr{r}r~r:�mainrrrr
�<module>s8*j



Youez - 2016 - github.com/yon3zu
LinuXploit