
    ;eE                         	 d dl Z d dlmZ d dlmZ d dlmZ  G d de j                  Z G d de j                  Z	e
d	k    r e j                     dS dS )
    N)	ALWAYS_EQ)Fraction)Decimalc                       e Zd Z	  G d d          Z G d d          Zdddd ed          gZdgd	d
 e            gZeez   Zd Zd Z	d Z
d Zd Zd Zd Zd
S )ComparisonSimpleTestc                       e Zd Zd ZdS )ComparisonSimpleTest.Emptyc                     dS )Nz<Empty> selfs    (/usr/lib/python3.11/test/test_compare.py__repr__z#ComparisonSimpleTest.Empty.__repr__   s    9    N)__name__
__module____qualname__r   r   r   r   Emptyr	      s#        	 	 	 	 	r   r   c                        e Zd Zd Zd Zd ZdS )ComparisonSimpleTest.Cmpc                     || _         d S Narg)r   r   s     r   __init__z!ComparisonSimpleTest.Cmp.__init__   s    DHHHr   c                     d| j         z  S )Nz<Cmp %s>r   r   s    r   r   z!ComparisonSimpleTest.Cmp.__repr__   s    ((r   c                     | j         |k    S r   r   r   others     r   __eq__zComparisonSimpleTest.Cmp.__eq__   s    8u$$r   N)r   r   r   r   r   r    r   r   r   Cmpr      sA        	 	 		) 	) 	)	% 	% 	% 	% 	%r   r!      g       @y       @           )   Nc                     | j         D ]O}| j         D ]E}|| j        v r	|| j        v s||u r|                     ||           /|                     ||           FPd S r   )
candidatesset1assertEqualassertNotEqualr   abs      r   test_comparisonsz%ComparisonSimpleTest.test_comparisons   s     	. 	.A_ . .$)^^!ty..a1ff$$Q****''1----	.	. 	.r   c           
          g }t          d          D ]:}|                    t          |          dz  |                                            ;|D ]*}|D ]%}|                     ||k    ||u d|d|           &+d S )N
   r"   za=z, b=)rangeinsertlenr   r(   )r   Lir+   r,   s        r   test_id_comparisonsz(ComparisonSimpleTest.test_id_comparisons%   s    r 	. 	.AHHSVVQY

---- 	H 	HA H H  aaAA1FGGGGH	H 	Hr   c                     |                      d          }|                      d          }|                      d          }|                     ||k    d           |                     ||k    d           |                     ||k    d           d S )Nr#   r"   TF)r!   assertIs)r   r+   r,   cs       r   test_ne_defaults_to_not_eqz/ComparisonSimpleTest.test_ne_defaults_to_not_eq.   s}    HHQKKHHQKKHHQKKa1fd###a1fe$$$a1fd#####r   c                     	 g  G fdd          } G fdd          } |             |            k     |                      ddg           d S )Nc                       e Zd Z fdZdS )8ComparisonSimpleTest.test_ne_high_priority.<locals>.Leftc                  <                         d           t          S )NLeft.__eq__appendNotImplementedargscallss    r   r    z?ComparisonSimpleTest.test_ne_high_priority.<locals>.Left.__eq__;       ]+++%%r   Nr   r   r   r    rD   s   r   Leftr<   9   .        & & & & & & &r   rH   c                   $    e Zd Z fdZ fdZdS )9ComparisonSimpleTest.test_ne_high_priority.<locals>.Rightc                  <                         d           t          S )NzRight.__eq__r?   rB   s    r   r    z@ComparisonSimpleTest.test_ne_high_priority.<locals>.Right.__eq__?       ^,,,%%r   c                  <                         d           t          S )NRight.__ne__r?   rB   s    r   __ne__z@ComparisonSimpleTest.test_ne_high_priority.<locals>.Right.__ne__B   rM   r   Nr   r   r   r    rP   rG   s   r   RightrK   >   G        & & & & && & & & & & &r   rR   r>   rO   assertSequenceEqual)r   rH   rR   rD   s      @r   test_ne_high_priorityz*ComparisonSimpleTest.test_ne_high_priority6   s    I	& 	& 	& 	& 	& 	& 	& 	& 	& 	&
	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	%%''  (GHHHHHr   c                     	 g  G fdd          } G fdd|          } |             |            k     |                      ddg           d S )Nc                       e Zd Z fdZdS )7ComparisonSimpleTest.test_ne_low_priority.<locals>.Basec                  <                         d           t          S )NBase.__eq__r?   rB   s    r   r    z>ComparisonSimpleTest.test_ne_low_priority.<locals>.Base.__eq__M   rE   r   NrF   rG   s   r   BaserY   K   rI   r   r\   c                   $    e Zd Z fdZ fdZdS ):ComparisonSimpleTest.test_ne_low_priority.<locals>.Derivedc                  <                         d           t          S )NzDerived.__eq__r?   rB   s    r   r    zAComparisonSimpleTest.test_ne_low_priority.<locals>.Derived.__eq__Q       -...%%r   c                  <                         d           t          S )NDerived.__ne__r?   rB   s    r   rP   zAComparisonSimpleTest.test_ne_low_priority.<locals>.Derived.__ne__T   r`   r   NrQ   rG   s   r   Derivedr^   P   rS   r   rc   rb   r[   rT   )r   r\   rc   rD   s      @r   test_ne_low_priorityz)ComparisonSimpleTest.test_ne_low_priorityH   s    B	& 	& 	& 	& 	& 	& 	& 	& 	& 	&
	& 	& 	& 	& 	& 	& 	&d 	& 	& 	& 	''))  )9=(IJJJJJr   c           	          	 dd fdd fdd fdd fd	d
 ff}|D ]\  }}                      |          5   fd G fdd          }|D ]\  }}||k    rt          ||           |dk    r5                      | |            t                                d           n1                     t
          | |            t                                 d d d            n# 1 swxY w Y   d S )Nr    c                     | |k    S r   r   r+   r,   s     r   <lambda>z<ComparisonSimpleTest.test_other_delegation.<locals>.<lambda>]   
    AF r   __lt__c                     | |k     S r   r   rg   s     r   rh   z<ComparisonSimpleTest.test_other_delegation.<locals>.<lambda>^   
    AE r   __le__c                     | |k    S r   r   rg   s     r   rh   z<ComparisonSimpleTest.test_other_delegation.<locals>.<lambda>_   ri   r   __gt__c                     | |k    S r   r   rg   s     r   rh   z<ComparisonSimpleTest.test_other_delegation.<locals>.<lambda>`   rl   r   __ge__c                     | |k    S r   r   rg   s     r   rh   z<ComparisonSimpleTest.test_other_delegation.<locals>.<lambda>a   ri   r   c                  2                         d           d S )Nz!Unexpected operator method called)fail)rC   r   s    r   
unexpectedz>ComparisonSimpleTest.test_other_delegation.<locals>.unexpectede   s    IIABBBBBr   c                       e Zd Z ZdS )5ComparisonSimpleTest.test_other_delegation.<locals>.CN)r   r   r   rP   )ru   s   r   Crw   g   s        'FFFr   rx   F)subTestsetattrr7   objectassertRaises	TypeError)r   opsnamefuncrx   r   _ru   s   `      @r   test_other_delegationz*ComparisonSimpleTest.test_other_delegationZ   s   F**+))***+))***+
  	F 	FJD$d## F FC C C C C( ( ( ( ( ( ( ( ( ( # 6 6HE1}}5*5558##MM$$qqssFHH"5"5u====%%iqqssFHHEEEF F F F F F F F F F F F F F F	F 	Fs   B C""C&	)C&	c                     d }|                      |t                     |                      t          |           t                      }|                      |t                     |                      t          |           d S )Nc                      d S r   r   r   r   r   rh   z6ComparisonSimpleTest.test_issue_1393.<locals>.<lambda>r   s    D r   )r(   r   r{   )r   xys      r   test_issue_1393z$ComparisonSimpleTest.test_issue_1393q   sp    LI&&&A&&&HHI&&&A&&&&&r   )r   r   r   r   r!   r'   set2r&   r-   r5   r9   rV   rd   r   r   r   r   r   r   r      s       D       % % % % % % % % sAtSSXX&DCtUUWW%DJ. . .H H H$ $ $I I I$K K K$F F F.' ' ' ' 'r   r   c            
          e Zd Z	  G d d          Z G d de          Z G d de          Z G d de          Z G d	 d
e          Z G d de          Z G d de          Z	 G d de          Z
 G d de          Z G d de          Z G d de          Zeeeeee	e
eeef
Zd Zd Zd*dZd Zd Zd Zd Zd Zd  Zd! Zd" Zd# Zd$ Zd% Zd& Zd' Zd( Zd) Z dS )+ComparisonFullTestc                       e Zd ZdS )ComparisonFullTest.CompBaseNr   r   r   r   r   r   CompBaser      s        	 	r   r   c                       e Zd ZdZdS )ComparisonFullTest.CompNoner   N)r   r   r   methr   r   r   CompNoner      s        r   r   c                       e Zd ZdZd ZdS )ComparisonFullTest.CompEq)eqc                 "    | j         |j         k    S r   r   r   s     r   r    z ComparisonFullTest.CompEq.__eq__       6UW$$r   N)r   r   r   r   r    r   r   r   CompEqr      (        	% 	% 	% 	% 	%r   r   c                       e Zd ZdZd ZdS )ComparisonFullTest.CompNe)nec                 "    | j         |j         k    S r   r   r   s     r   rP   z ComparisonFullTest.CompNe.__ne__   r   r   N)r   r   r   r   rP   r   r   r   CompNer      r   r   r   c                       e Zd ZdZd Zd ZdS )ComparisonFullTest.CompEqNe)r   r   c                 "    | j         |j         k    S r   r   r   s     r   r    z"ComparisonFullTest.CompEqNe.__eq__   r   r   c                 "    | j         |j         k    S r   r   r   s     r   rP   z"ComparisonFullTest.CompEqNe.__ne__   r   r   N)r   r   r   r   r    rP   r   r   r   CompEqNer      7        	% 	% 	%	% 	% 	% 	% 	%r   r   c                       e Zd ZdZd ZdS )ComparisonFullTest.CompLt)ltc                 "    | j         |j         k     S r   r   r   s     r   rj   z ComparisonFullTest.CompLt.__lt__       6EG##r   N)r   r   r   r   rj   r   r   r   CompLtr      (        	$ 	$ 	$ 	$ 	$r   r   c                       e Zd ZdZd ZdS )ComparisonFullTest.CompGt)gtc                 "    | j         |j         k    S r   r   r   s     r   ro   z ComparisonFullTest.CompGt.__gt__   r   r   N)r   r   r   r   ro   r   r   r   CompGtr      r   r   r   c                       e Zd ZdZd Zd ZdS )ComparisonFullTest.CompLtGt)r   r   c                 "    | j         |j         k     S r   r   r   s     r   rj   z"ComparisonFullTest.CompLtGt.__lt__   r   r   c                 "    | j         |j         k    S r   r   r   s     r   ro   z"ComparisonFullTest.CompLtGt.__gt__   r   r   N)r   r   r   r   rj   ro   r   r   r   CompLtGtr      s7        	$ 	$ 	$	$ 	$ 	$ 	$ 	$r   r   c                       e Zd ZdZd ZdS )ComparisonFullTest.CompLe)lec                 "    | j         |j         k    S r   r   r   s     r   rm   z ComparisonFullTest.CompLe.__le__   r   r   N)r   r   r   r   rm   r   r   r   CompLer      r   r   r   c                       e Zd ZdZd ZdS )ComparisonFullTest.CompGe)gec                 "    | j         |j         k    S r   r   r   s     r   rq   z ComparisonFullTest.CompGe.__ge__   r   r   N)r   r   r   r   rq   r   r   r   CompGer      r   r   r   c                       e Zd ZdZd Zd ZdS )ComparisonFullTest.CompLeGe)r   r   c                 "    | j         |j         k    S r   r   r   s     r   rm   z"ComparisonFullTest.CompLeGe.__le__   r   r   c                 "    | j         |j         k    S r   r   r   s     r   rq   z"ComparisonFullTest.CompLeGe.__ge__   r   r   N)r   r   r   r   rm   rq   r   r   r   CompLeGer      r   r   r   c                     	 fdt          t          |                    D             }|                    t                     t	          ||          D ]\  }}||_        |S )Nc                 $    g | ]}             S r   r   ).0__class_s     r   
<listcomp>z>ComparisonFullTest.create_sorted_instances.<locals>.<listcomp>   s    ;;;"VVXX;;;r   )key)r0   r2   sortidzipr   )r   r   values	instancesinstvalues    `    r   create_sorted_instancesz*ComparisonFullTest.create_sorted_instances   sq    		 <;;;c&kk(:(:;;;	2y&11 	 	KD%DFFr   c                 n   	 |                      ||k    |           |                      ||k    |           |                      ||k    |            |                      ||k    |            |                     t          d          5  ||k      d d d            n# 1 swxY w Y   |                     t          d          5  ||k     d d d            n# 1 swxY w Y   |                     t          d          5  ||k     d d d            n# 1 swxY w Y   |                     t          d          5  ||k     d d d            n# 1 swxY w Y   |                     t          d          5  ||k      d d d            n# 1 swxY w Y   |                     t          d          5  ||k     d d d            n# 1 swxY w Y   |                     t          d          5  ||k     d d d            n# 1 swxY w Y   |                     t          d          5  ||k     d d d            d S # 1 swxY w Y   d S )Nnot supportedr(   assertRaisesRegexr}   )r   r+   r,   equals       r   assert_equality_onlyz'ComparisonFullTest.assert_equality_only   s$   	
 	a'''a'''aU+++aU+++##I?? 	 	EE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##I?? 	 	FF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##I?? 	 	EE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##I?? 	 	FF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##I?? 	 	EE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##I?? 	 	FF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##I?? 	 	EE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##I?? 	 	FF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   BB!B CCC9DDD2EE	E	+E>>FF$F77F;>F;G00G47G4H**H.1H.Nc                 4   	 |                      |||||           |                     |||||           |                     |||||           |                     |||||           |                     |||||           |                     |||||           d S r   )assert_eq_subtestassert_ne_subtestassert_lt_subtestassert_le_subtestassert_gt_subtestassert_ge_subtestr   r+   r,   compa_methb_meths         r   assert_total_orderz%ComparisonFullTest.assert_total_order   s    	 	q!T66:::q!T66:::q!T66:::q!T66:::q!T66:::q!T66:::::r   c                    |d|v sd|v r>|                      ||k    |dk               |                      ||k    |dk               d S |                      ||k    ||u            |                      ||k    ||u            d S )Nr   r   )r(   r   s         r   r   z$ComparisonFullTest.assert_eq_subtest  s    >TV^^tv~~Q!VTQY///Q!VTQY/////Q!VQ!V,,,Q!VQ!V,,,,,r   c                 *   |ddh                     ||z             s>|                     ||k    |dk               |                     ||k    |dk               d S |                     ||k    ||u           |                     ||k    ||u           d S )Nr   r   r   )
isdisjointr(   r   s         r   r   z$ComparisonFullTest.assert_ne_subtest  s    >$!8!8&!I!I>Q!VTQY///Q!VTQY/////Q!VQaZ000Q!VQaZ00000r   c                 |   |d|v sd|v r>|                      ||k     |dk                |                      ||k    |dk                d S |                     t          d          5  ||k      d d d            n# 1 swxY w Y   |                     t          d          5  ||k     d d d            d S # 1 swxY w Y   d S )Nr   r   r   r   r   r   s         r   r   z$ComparisonFullTest.assert_lt_subtest'  P   >TV^^tv~~QUD1H---QUD1H-----''	?CC  A              ''	?CC  A                 $   $A77A;>A;B11B58B5c                 |   |d|v sd|v r>|                      ||k    |dk               |                      ||k    |dk               d S |                     t          d          5  ||k     d d d            n# 1 swxY w Y   |                     t          d          5  ||k     d d d            d S # 1 swxY w Y   d S )Nr   r   r   r   r   r   s         r   r   z$ComparisonFullTest.assert_le_subtest1  P   >TV^^tv~~Q!VTQY///Q!VTQY/////''	?CC  Q              ''	?CC  Q                 r   c                 |   |d|v sd|v r>|                      ||k    |dk               |                      ||k     |dk               d S |                     t          d          5  ||k     d d d            n# 1 swxY w Y   |                     t          d          5  ||k      d d d            d S # 1 swxY w Y   d S )Nr   r   r   r   r   r   s         r   r   z$ComparisonFullTest.assert_gt_subtest;  r   r   c                 |   |d|v sd|v r>|                      ||k    |dk               |                      ||k    |dk               d S |                     t          d          5  ||k     d d d            n# 1 swxY w Y   |                     t          d          5  ||k     d d d            d S # 1 swxY w Y   d S )Nr   r   r   r   r   r   s         r   r   z$ComparisonFullTest.assert_ge_subtestE  r   r   c                     	 t                      }t                      }|                     ||d           |                     ||d           d S )NTF)r{   r   r*   s      r   test_objectszComparisonFullTest.test_objectsO  sM    1HHHH!!!Q---!!!Q.....r   c           	         	 | j         D ]}|                     |          5  |                     |d          }|                     |d         |d         d|j        |j                   |                     |d         |d         d|j        |j                   |                     |d         |d         d|j        |j                   |                     |d         |d         d|j        |j                   d d d            n# 1 swxY w Y   d S )N)r#   r"   r#   r   r"   r#   )all_comp_classesry   r   r   r   )r   clsr   s      r   test_comp_classes_samez)ComparisonFullTest.test_comp_classes_sameV  sb   C( 	< 	<Cc"" < < 88iHH	 ''	!ilA(+#(< < < ''	!ilA(+#(< < < ''	!ilB(+#(< < < ''	!ilB(+#(< < <%< < < < < < < < < < < < < < <	< 	<s   CD  D	D	c           
         	 | j         D ]}| j         D ]}|                     ||          5   |            }d|_         |            }d|_         |            }d|_        |                     ||d|j        |j                   |                     ||d|j        |j                   d d d            n# 1 swxY w Y   d S )Nrg   r#   r"   r   r   )r   ry   r   r   r   )r   cls_acls_ba1b1b2s         r   test_comp_classes_differentz.ComparisonFullTest.test_comp_classes_differento  s(   H* 	< 	<E. < <\\EU\33 < <BBDBBDBBD++B5:uz; ; ;++BEJ
< < << < < < < < < < < < < < < < <<	< 	<s   A:B11B58B5c                 J   	  G d dt                     }t          d          }t          d          } |d          } |d          } |d          }|                     ||d           |                     ||d           |                     ||d           |                     ||d           |                     ||d           |                     ||d           |                     ||d           |                     ||d           |                     ||d           d S )Nc                       e Zd ZdS )9ComparisonFullTest.test_str_subclass.<locals>.StrSubclassNr   r   r   r   StrSubclassr    s        Dr   r  r+   r,   r   r   )strr   )r   r  s1s2c1c2c3s          r   test_str_subclassz$ComparisonFullTest.test_str_subclass  sR   6	 	 	 	 	# 	 	 	 XXXX[[[B!,,,B+++B!,,,B+++B!,,,B+++B!,,,B+++B!,,,,,r   c                 
   	 d}d}|                      ||d           |                      ||d           d}d}|                      ||d           |                      ||d           t          dd          }t          d	d          }|                      ||d           |                      ||d           t          d
          }t          d          }|                      ||d           |                      ||d           d}	d}
|                     |	|	d           |                     |	|
d           ||f||f||f||f||f||ffD ]\  }}|                      ||d           ||||fD ]}|                     ||	d           d S )Ni  i  r   r   g     H@gH@i  r"   i  z1001.0z1001.1y     H@        y     H@      ?TF)r   r   r   r   )r   i1i2f1f2q1q2d1d2r  r  n1n2s                r   test_numberszComparisonFullTest.test_numbers  s   # B***B+++B***B+++dAdAB***B+++XXB***B+++!!"b$///!!"b%000 2wB"R2b'Br7RGL 	/ 	/FB##BA....r2r" 	4 	4B%%b"d3333	4 	4r   c                    	 ddg}ddg}|                      ||d           |                      ||d           d}d}|                      ||d           |                      ||d           t          dd          }t          dd          }|                     ||d           |                     ||d	           |                     ||d	           |                     ||d	           |                     ||d	           d S )
Nr#   r"   r$   r   r   r#   r"   r"   r$   TF)r   r0   r   )r   l1l2t1t2r1r2s          r   test_sequencesz!ComparisonFullTest.test_sequences  s   -VVB***B+++B***B+++1a[[1a[[!!"b$///!!"b%000!!"b%000!!"b%000!!"b%00000r   c                    	 d}d}|                      ||d           |                      ||d           t          d          }t          d          }|                      ||d           |                      ||d           |                      ||d           |                      ||d           |                      ||d           |                      ||d           d S )Ns   a1s   b2r   r   )r   	bytearray)r   bs1bs2ba1ba2s        r   
test_byteszComparisonFullTest.test_bytes  s    *S!,,,S"---S1---S"---S!,,,S"---S!,,,S"-----r   c                    	 ddh}h d}|                      ||d           |                      ||d           t          |          }t          |          }|                      ||d           |                      ||d           |                      ||d           |                      ||d           |                      ||d           |                      ||d           d S )Nr#   r"   >   r#   r"   r$   r   r   )r   	frozenset)r   r  r  r  r  s        r   	test_setszComparisonFullTest.test_sets  s    (VYYB***B+++r]]r]]B+++B+++B***B+++B***B+++++r   c                     	 ddd}ddd}ddd}|                      ||d           |                      ||d           |                      ||d           d S )	Nr+   r,   r  r8   r  )r$   r"   TF)r   )r   r  r  d3s       r   test_mappingsz ComparisonFullTest.test_mappings  s|    	!!"b$///!!"b%000!!"b$/////r   )NN)!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	  r  r  r&  r)  r,  r   r   r   r   r   z   s       
           8   % % % % % % % %
% % % % % % % %
% % % % %8 % % %$ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $
$ $ $ $ $8 $ $ $% % % % % % % %
% % % % % % % %
% % % % %8 % % % FHFHFH	&  &  6; ; ; ;8- - -1 1 1        / / /< < <2< < <$- - -,"4 "4 "4H1 1 1*. . .", , ,"0 0 0 0 0r   r   __main__)unittesttest.supportr   	fractionsr   decimalr   TestCaser   r   r   mainr   r   r   <module>r4     s    *  " " " " " "            o' o' o' o' o'8, o' o' o'd@0 @0 @0 @0 @0* @0 @0 @0F zHMOOOOO r   