Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_binop.cpython-312.pyc

�

&Μg�8��$�dZddlZddlmZmZmZddlmZd�Zd�Z	d�Z
d�ZGd	�d
e�Z
Gd�dej�ZGd
�d�Zd�ZGd�de�ZGd�dee��ZGd�de�ZGd�de�Zej-e�Gd�dej�ZGd�de�ZGd�de�ZGd�d e�ZGd!�d"e�ZGd#�d$e�ZGd%�d&�ZGd'�d(ej�Zed)k(rej@�yy)*z9Tests for binary operators on subtypes of built-in types.�N)�eq�le�ne)�ABCMetac��|r
||z|}}|r�
|S)z1Greatest common divisor using Euclid's algorithm.�)�a�bs  �,/usr/local/lib/python3.12/test/test_binop.py�gcdrs��
���s�A�1����H�c�"�t|t�S)z-Test whether an object is an instance of int.)�
isinstance�int��xs r�isintr
����a���r
c�L�tttfD]}t||�s�yy)zATest whether an object is an instance of a built-in numeric type.�r)r�float�complexr)r�Ts  r�isnumrs%��
�%��
 ���a����!�
r
c�"�t|t�S)z7Test whether an object is an instance of the Rat class.)r�Ratrs r�isRatrrr
c��eZdZdZddgZdd�Zd�Zeed�Zd�Z	ee	d�Z
d�Zd	�Zd
�Z
d�Zd�ZeZd
�Zd�Zd�ZeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)rz9Rational number implemented as a normalized pair of ints.�	_Rat__num�	_Rat__denc���t|�std|z��t|�std|z��|dk(rtd��t||�}t	||z�|_t	||z�|_y)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rrr )�self�num�den�gs    r�__init__zRat.__init__"sp���S�z��<�s�B�C�C��S�z��>��D�E�E��!�8�#�$6�7�7���S�M����a��[��
���a��[��
r
c��|jS)z7Accessor function for read-only 'num' attribute of Rat.)r�r$s r�_get_numzRat._get_num1����z�z�r
Nc��|jS)z7Accessor function for read-only 'den' attribute of Rat.)r r*s r�_get_denzRat._get_den6r,r
c�8�d|j|jfzS)z<Convert a Rat to a string resembling a Rat constructor call.zRat(%d, %d)�rr r*s r�__repr__zRat.__repr__;s����
�
�D�J�J�7�7�7r
c�*�tt|��S)z=Convert a Rat to a string resembling a decimal numeric value.)�strrr*s r�__str__zRat.__str__?s���5��;��r
c�:�|jdz|jzS)zConvert a Rat to a float.��?r0r*s r�	__float__z
Rat.__float__Cs���z�z�#�~�d�j�j�(�(r
c���|jdk(r	t|j�Stdt	|�z��#t$rtdt	|�z��wxYw)z,Convert a Rat to an int; self.den must be 1.rz%s too large to convert to intzcan't convert %s to int)r rr�
OverflowError�repr�
ValueErrorr*s r�__int__zRat.__int__Gsd���:�:��?�
2��4�:�:��&��2�T�$�Z�?�@�@��!�
2�#�$D�&*�4�j�%1�2�2�
2�s	�=�!Ac�*�t|�rt|�}t|�rTt|j|jz|j|jzz|j|jz�St|�rt
|�|zStS)z$Add two Rats, or a Rat and a number.�rrrrr rr�NotImplemented�r$�others  r�__add__zRat.__add__Q�s����<���J�E���<��t�z�z�%�+�+�-����D�J�J�0F�F��z�z�%�+�+�-�/�
/���<���;��&�&��r
c�*�t|�rt|�}t|�rTt|j|jz|j|jzz
|j|jz�St|�rt
|�|z
StS)z)Subtract two Rats, or a Rat and a number.r>r@s  r�__sub__zRat.__sub__^rCr
c�*�t|�rt|�}t|�rTt|j|jz|j|jzz
|j|jz�St|�r|t
|�z
StS)z9Subtract two Rats, or a Rat and a number (reversed args).r>r@s  r�__rsub__zRat.__rsub__iss����<���J�E���<��u�{�{�4�:�:�-��
�
�5�;�;�0F�F��z�z�%�+�+�-�/�
/���<��5��;�&�&��r
c�&�t|�r:t|j|jz|j|jz�St	|�r#t|j|z|j�St|�rt
|�|zStS)z)Multiply two Rats, or a Rat and a number.�rrrr rrrr?r@s  r�__mul__zRat.__mul__tsm����<��t�z�z�%�+�+�-�t�z�z�%�+�+�/E�F�F���<��t�z�z�%�'����4�4���<���;�u�$�$��r
c�&�t|�r:t|j|jz|j|jz�St	|�r#t|j|j|z�St|�rt
|�|zStS)z'Divide two Rats, or a Rat and a number.rIr@s  r�__truediv__zRat.__truediv__�sm����<��t�z�z�%�+�+�-�t�z�z�%�+�+�/E�F�F���<��t�z�z�4�:�:�e�#3�4�4���<���;��&�&��r
c�&�t|�r:t|j|jz|j|jz�St	|�r#t||jz|j�St|�r|t
|�zStS)z7Divide two Rats, or a Rat and a number (reversed args).rIr@s  r�__rtruediv__zRat.__rtruediv__�sm����<��u�{�{�4�:�:�-�u�{�{�4�:�:�/E�F�F���<��u�T�Z�Z�'����4�4���<��5��;�&�&��r
c��t|�rt|�}nt|�stS||z}|j|j
zS)z.Divide two Rats, returning the floored result.)rrrr?rr �r$rArs   r�__floordiv__zRat.__floordiv__�s;����<���J�E��u��!�!���J���w�w�!�'�'�!�!r
c�>�||z}|j|jzS)z>Divide two Rats, returning the floored result (reversed args).r0rPs   r�
__rfloordiv__zRat.__rfloordiv__�s���$�J���w�w�!�'�'�!�!r
c�p�t|�rt|�}nt|�stS||z}||||zz
fS)z2Divide two Rats, returning quotient and remainder.)rrrr?rPs   r�
__divmod__zRat.__divmod__�s<����<���J�E��u��!�!��%�K���4�%�!�)�#�$�$r
c�j�t|�rt|�}nt|�stSt	||�S)zBDivide two Rats, returning quotient and remainder (reversed args).)rrrr?�divmodr@s  r�__rdivmod__zRat.__rdivmod__�s,����<���J�E��u��!�!��e�T�"�"r
c� �t||�dS)zTake one Rat modulo another.r�rWr@s  r�__mod__zRat.__mod__�s���d�E�"�1�%�%r
c� �t||�dS)z,Take one Rat modulo another (reversed args).rrZr@s  r�__rmod__zRat.__rmod__�s���e�T�"�1�%�%r
c��t|�r |jdk(xr|j|k(St|�r4|j|jk(xr|j|jk(St	|�rt|�|k(StS)zCompare two Rats for equality.r)rr rrrrr?r@s  r�__eq__z
Rat.__eq__�sm����<��:�:��?�:�t�z�z�U�':�:���<��:�:����,�J����u�{�{�1J�J���<���;�%�'�'��r
)rr)�__name__�
__module__�__qualname__�__doc__�	__slots__r(r+�propertyr%r.r&r1r4r7r<rB�__radd__rErGrJ�__rmul__rLrNrQrSrUrXr[r]r_rr
rrrs���C��k�*�I�
!���8�T�
"�C���8�T�
"�C�8� �)�A�	��H�	�	���H���"�"�
%�#�&�&�r
rc�F�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�RatTestCasez3Unit tests for Rat class and its support utilities.c���|jtdd�d�|jtdd�d�|jtdd�d�|jtdd�d�|jtd	d�d
�|jtdd
�d�|jtd	d
�d
�tdd�D]�}tdd�D]~}|jt||�dkD�|jt||�dk�|jt||�dkD�|jt||�dk�����y)
N�
�����r�d�������r)�assertEqualr�range�
assertTrue)r$�i�js   r�test_gcdzRatTestCase.test_gcd�s������R���a�(�����R���a�(�����R���a�(�����S�"��q�)�����S�!��b�)�����R���a�(�����S�"��r�*��q�"��A��1�b�\������A�q�	�A�
�.�����Q�B��
�Q��/�����A��r�
�Q��/�����Q�B����a��0�	"�r
c	���tdd�}|j|jd�|j|jd�tdd�}|j|jd�|j|jd�tdd�}|j|jd�|j|jd�tdd�}|j|jd�|j|jd�td�}|j|jd�|j|jd	�	td	d
�}|j	d�dd
ddgidttf	D]C}	t|�}|j	d|z�	td	|�}|j	d|z��Ey#t
$rY�ewxYw#t$rY�>wxYw#t$rY�pwxYw)Nrkrnrm�i�rsrr�rrz(Rat(1, 0) didn't raise ZeroDivisionError�0gyrzRat(%r) didn't raise TypeErrorz!Rat(1, %r) didn't raise TypeError)rrur%r&�failr#�unittestr")r$r	�bads   r�test_constructorzRatTestCase.test_constructor�s�����B�K���������"��������"���C�L���������#��������"���R�L���������#��������"���S�M���������"��������"���F���������"��������"�	B��A�q�	�A�
�I�I�@�A���R��R��T�3��@�C�
B���H���	�	�:�S�@�A�
E���3�K���	�	�=��C�D�A��	!�	��	���
��
���
��
�s6�G�	G�)G*�	G�G�	G'�&G'�*	G6�5G6c�v�|jtdd�tdd�zd�|jtdd�dztdd��|jdtdd�ztdd��|jdtdd�zd�|jtdd�dzd�y)Nrmr|rror6��?�rurr*s r�test_addzRatTestCase.test_add�s�������Q���S��A�Y�.��2�����Q���Q���A�q�	�2�����S��A�Y���A�q�	�2�����s�1�a�y��#�.�����Q���S��#�.r
c��|jtdd�tdd�z
tdd��|jtdd�dz
tdd��|jdtdd�z
tdd��|jtdd�dz
d	�|jdtdd�z
d	�y)
Nr}rmro�rkrr|r6��?r�r*s r�test_subzRatTestCase.test_subs�������Q���S��A�Y�.��B���<�����Q���Q���A�q�	�2�����S��A�Y���A�q�	�2�����Q���S��#�.�����s�1�a�y��#�.r
c�b�|jtdd�tdd�ztdd��|jtdd�dzd�|jdtdd�zd�|jtdd�dzd�|jdtdd�zd�y)	Nrmr|ror}rkr�r�r6r�r*s r�test_mulzRatTestCase.test_mul	s�������Q���S��A�Y�.��B���<�����R���a���,�����S��Q�Z���,�����R���c�)�3�/�����s�2�q�z�)�3�/r
c��|jtdd�tdd�ztdd��|jtdd�dztdd��|jdtd�ztdd��|jdtd	d�zd
�|jtd	d�dzd
�y)Nrkr|ror}��	rm�@rr�r�r*s r�test_divzRatTestCase.test_divs�������R���c�!�Q�i�/��R���<�����R���a���R���4�����S��V��S��A�Y�/�����s�1�a�y��#�.�����Q���S��#�.r
c��|jtd�td�zd�|jtdd�tdd�zd�|jtd�dzd�|jdtd�zd�y)Nrk�rmr|r�r*s r�
test_floordivzRatTestCase.test_floordivsp������R��C��F�*�A�.�����R���s�1�a�y�0�!�4�����R��A��q�)�����s�1�v��q�)r
c�&�|jtd�tdd��|jtd�d�|jdtd��|jtd�d�|jdtd��y)Nrkrtrmg$@r�r*s r�test_eqzRatTestCase.test_eqsl������R��#�b�!�*�-�����R��"�%�����S��W�%�����R��$�'�����s�2�w�'r
c��|jtdd�tdd�ztdd��|jtdd�dztdd��|jdtd�ztdd��|jdtd	d�zd
�|jtd	d�dzd
�|jtd�d�y)
Nrkr|ror}r�r�rmr�rr�z1/2r�)rur�evalr*s r�
test_true_divzRatTestCase.test_true_div$s�������R���c�!�Q�i�/��R���<�����R���a���R���4�����S��V��S��A�Y�/�����s�1�a�y��#�.�����Q���S��#�.�����e��c�*r
N)
r`rarbrcrzr�r�r�r�r�r�r�r�rr
rriri�s4��=�
1�"E�H/�/�0�/�*�(�+r
ric��eZdZdZd�Zd�Zy)�OperationLoggerz.Base class for classes with operation logging.c��||_y�N��logger)r$r�s  rr(zOperationLogger.__init__1s	����r
c�"�|j|�yr�r�)r$�argss  r�
log_operationzOperationLogger.log_operation3s������T�r
N)r`rarbrcr(r�rr
rr�r�/s��8��r
r�c��g}g}|D]#}|j||j���%	||�|S#t$rY|SwxYw)zvReturn the sequence of operations that results from applying
    the operation `op` to instances of the given classes.)�appendr")�op�classes�log�	instances�cs     r�op_sequencer�6sZ��
�C��I�
������3�:�:��'��
�
�I���J���
���J�
�s�5�	A�Ac��eZdZd�Zd�Zd�Zy)�Ac�0�|jd�tS)N�A.__eq__�r�r?r@s  rr_zA.__eq__E������:�&��r
c�0�|jd�tS)N�A.__le__r�r@s  r�__le__zA.__le__Hr�r
c�0�|jd�tS)N�A.__ge__r�r@s  r�__ge__zA.__ge__Kr�r
N�r`rarbr_r�r�rr
rr�r�D�����r
r�c��eZdZd�Zd�Zd�Zy)�Bc�0�|jd�tS)N�B.__eq__r�r@s  rr_zB.__eq__Pr�r
c�0�|jd�tS)N�B.__le__r�r@s  rr�zB.__le__Sr�r
c�0�|jd�tS)N�B.__ge__r�r@s  rr�zB.__ge__Vr�r
Nr�rr
rr�r�Or�r
r�)�	metaclassc��eZdZd�Zd�Zd�Zy)�Cc�0�|jd�tS)N�C.__eq__r�r@s  rr_zC.__eq__[r�r
c�0�|jd�tS)N�C.__le__r�r@s  rr�zC.__le__^r�r
c�0�|jd�tS)N�C.__ge__r�r@s  rr�zC.__ge__ar�r
Nr�rr
rr�r�Zr�r
r�c�"�eZdZdZd�Zd�Zd�Zy)�VzVirtual subclass of Bc�0�|jd�tS)N�V.__eq__r�r@s  rr_zV.__eq__gr�r
c�0�|jd�tS)NzV.__le__r�r@s  rr�zV.__le__jr�r
c�0�|jd�tS)N�V.__ge__r�r@s  rr�zV.__ge__mr�r
N)r`rarbrcr_r�r�rr
rr�r�es�����r
r�c��eZdZd�Zy)�OperationOrderTestsc�R�|jtttt�ddg�|jtttt�ddg�|jtttt�ddg�|jtttt
�ddg�|jttt
t�ddg�|jtttt�ddg�|jtttt�ddg�|jtttt�ddg�|jtttt
�ddg�|jttt
t�d	dg�|jttt��|jtttt�dd
g�|jtttt�ddg�y)Nr�r�r�r�r�r�r�r�r�r�r�)
rur�rr�r�r�rrw�
issubclassr�r*s r�test_comparison_ordersz*OperationOrderTests.test_comparison_ordersts}������R��A�.��Z�0H�I�����R��A�.��Z�0H�I�����R��A�.��Z�0H�I�����R��A�.��Z�0H�I�����R��A�.��Z�0H�I�����R��A�.��Z�0H�I�����R��A�.��Z�0H�I�����R��A�.��Z�0H�I�����R��A�.��Z�0H�I�����R��A�.��Z�0H�I����
�1�a�(�)�����R��A�.��Z�0H�I�����R��A�.��Z�0H�Ir
N)r`rarbr�rr
rr�r�ss��Jr
r�c��eZdZdZd�Zy)�SupEqzClass that can test equalityc��y�NTrr@s  rr_zSupEq.__eq__����r
N�r`rarbrcr_rr
rr�r��s
��&�r
r�c��eZdZdZdZy)�Sz"Subclass of SupEq that should failNr�rr
rr�r���
��,�
�Fr
r�c��eZdZdZy)�Fz'Independent class that should fall backN)r`rarbrcrr
rr�r��s��1r
r�c��eZdZdZdZy)�Xz"Independent class that should failNr�rr
rr�r��r�r
r�c��eZdZdZdZy)�SNz>Subclass of SupEq that can test equality, but not non-equalityN)r`rarbrc�__ne__rr
rr�r��s
��H�
�Fr
r�c��eZdZdZd�ZdZy)�XNz>Independent class that can test equality, but not non-equalityc��yr�rr@s  rr_z	XN.__eq__�r�r
N)r`rarbrcr_r�rr
rr�r��s��H��
�Fr
r�c��eZdZdZd�Zd�Zy)�FallbackBlockingTestsz#Unit tests for None method blockingc��t�t�t�t�f\}}}}|j	||�|j	||�|j	||�|j	||�|jtt||�|jtt||�|jtt||�yr�)r�r�r�r�ru�assertRaisesr"r)r$�e�f�srs     r�test_fallback_rmethod_blockingz4FallbackBlockingTests.test_fallback_rmethod_blocking�s����W�a�c�1�3���+�
��1�a������A������A������A������A�����)�R��A�.����)�R��A�.����)�R��A�.r
c�8�t�t�t�}}}|j||k7�|j	t
t||�|j	t
t||�|j||k7�|j	t
t||�yr�)r�r�r��assertFalser�r"r)r$r��sn�xns    r�test_fallback_ne_blockingz/FallbackBlockingTests.test_fallback_ne_blocking�su���G�R�T�2�4�r�2������a�� ����)�R��B�/����)�R��Q�/�����b��!����)�R��Q�/r
N)r`rarbrcr�r�rr
rr�r��s��-�
/�0r
r��__main__)!rcr��operatorrrr�abcrrrrr�objectr�TestCaserir�r�r�r�r�r��registerr�r�r�r�r�r�r�r�r`�mainrr
r�<module>r�s ��?�����
��
��g�&�g�Re+�(�#�#�e+�T���	��	�	��7�	�	��	�
��
��
�
�1�
�J�(�+�+�J�&�F��
���2��2���������0�H�-�-�0�.�z���H�M�M�O�r

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