a
    ze                     @   sV   d dl Z d dlmZ G dd dZG dd dZG dd de jZed	krRe   dS )
    N)	ALWAYS_EQc                   @   s   e Zd Zdd ZdS )Emptyc                 C   s   dS )Nz<Empty> selfr   r   '/usr/lib/python3.9/test/test_compare.py__repr__   s    zEmpty.__repr__N)__name__
__module____qualname__r   r   r   r   r   r      s   r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )Cmpc                 C   s
   || _ d S Narg)r   r   r   r   r   __init__	   s    zCmp.__init__c                 C   s
   d| j  S )Nz<Cmp %s>r   r   r   r   r   r      s    zCmp.__repr__c                 C   s
   | j |kS r   r   )r   otherr   r   r   __eq__   s    z
Cmp.__eq__N)r	   r
   r   r   r   r   r   r   r   r   r      s   r   c                   @   sn   e Zd ZddddedgZdgdde gZee Zdd Zd	d
 Z	dd Z
dd Zdd Zdd Zdd ZdS )ComparisonTest   g       @y       @           )   Nc                 C   sR   | j D ]F}| j D ]:}|| jv r(|| jv s0||u r>| || q| || qqd S r   )
candidatesset1assertEqualZassertNotEqual)r   abr   r   r   test_comparisons   s
    

zComparisonTest.test_comparisonsc              	   C   sf   g }t dD ]}|t|d t  q|D ]4}|D ]*}| ||kt|t|kd||f  q4q,d S )N
   r   z
a=%r, b=%r)rangeinsertlenr   r   id)r   Lir   r   r   r   r   test_id_comparisons   s    
z"ComparisonTest.test_id_comparisonsc                 C   sL   t d}t d}t d}| ||kd | ||kd | ||kd d S )Nr   r   TF)r   assertIs)r   r   r   cr   r   r   test_ne_defaults_to_not_eq)   s    z)ComparisonTest.test_ne_defaults_to_not_eqc                    sH   g  G  fddd}G  fddd}| | k |   ddg dS )z;object.__ne__() should allow reflected __ne__() to be triedc                       s   e Zd Z fddZdS )z2ComparisonTest.test_ne_high_priority.<locals>.Leftc                     s     d tS )NLeft.__eq__appendNotImplementedargsZcallsr   r   r   6   s    
z9ComparisonTest.test_ne_high_priority.<locals>.Left.__eq__Nr	   r
   r   r   r   r.   r   r   Left4   s   r0   c                       s$   e Zd Z fddZ fddZdS )z3ComparisonTest.test_ne_high_priority.<locals>.Rightc                     s     d tS )NzRight.__eq__r)   r,   r.   r   r   r   :   s    
z:ComparisonTest.test_ne_high_priority.<locals>.Right.__eq__c                     s     d tS )NRight.__ne__r)   r,   r.   r   r   __ne__=   s    
z:ComparisonTest.test_ne_high_priority.<locals>.Right.__ne__Nr	   r
   r   r   r2   r   r.   r   r   Right9   s   r4   r(   r1   NZassertSequenceEqual)r   r0   r4   r   r.   r   test_ne_high_priority1   s
    z$ComparisonTest.test_ne_high_priorityc                    sJ   g  G  fddd}G  fddd|}| | k |   ddg dS )z4object.__ne__() should not invoke reflected __eq__()c                       s   e Zd Z fddZdS )z1ComparisonTest.test_ne_low_priority.<locals>.Basec                     s     d tS )NBase.__eq__r)   r,   r.   r   r   r   H   s    
z8ComparisonTest.test_ne_low_priority.<locals>.Base.__eq__Nr/   r   r.   r   r   BaseF   s   r8   c                       s$   e Zd Z fddZ fddZdS )z4ComparisonTest.test_ne_low_priority.<locals>.Derivedc                     s     d tS )NzDerived.__eq__r)   r,   r.   r   r   r   L   s    
z;ComparisonTest.test_ne_low_priority.<locals>.Derived.__eq__c                     s     d tS )NDerived.__ne__r)   r,   r.   r   r   r2   O   s    
z;ComparisonTest.test_ne_low_priority.<locals>.Derived.__ne__Nr3   r   r.   r   r   DerivedK   s   r:   r9   r7   Nr5   )r   r8   r:   r   r.   r   test_ne_low_priorityC   s
    z#ComparisonTest.test_ne_low_priorityc              	      s   ddd fddd fddd fdd	d fd
dd ff}|D ]\}}  |  fddG fddd}|D ]\}}||krpt|| qp|dkr || t d n t|| t  W d   q:1 s0    Y  q:dS )z8No default delegation between operations except __ne__()r   c                 S   s   | |kS r   r   r   r   r   r   r   <lambda>X       z6ComparisonTest.test_other_delegation.<locals>.<lambda>__lt__c                 S   s   | |k S r   r   r<   r   r   r   r=   Y   r>   __le__c                 S   s   | |kS r   r   r<   r   r   r   r=   Z   r>   __gt__c                 S   s   | |kS r   r   r<   r   r   r   r=   [   r>   __ge__c                 S   s   | |kS r   r   r<   r   r   r   r=   \   r>   c                     s     d d S )Nz!Unexpected operator method called)Zfailr,   r   r   r   
unexpected`   s    z8ComparisonTest.test_other_delegation.<locals>.unexpectedc                       s   e Zd Z ZdS )z/ComparisonTest.test_other_delegation.<locals>.CN)r	   r
   r   r2   r   )rC   r   r   Cb   s   rD   FN)ZsubTestsetattrr%   objectZassertRaises	TypeError)r   opsnamefuncrD   r   _r   )r   rC   r   test_other_delegationU   s     




z$ComparisonTest.test_other_delegationc                 C   sB   dd }|  |t |  t| t }|  |t |  t| d S )Nc                   S   s   d S r   r   r   r   r   r   r=   m   r>   z0ComparisonTest.test_issue_1393.<locals>.<lambda>)r   r   rF   )r   xyr   r   r   test_issue_1393l   s    zComparisonTest.test_issue_1393)r	   r
   r   r   r   r   Zset2r   r   r$   r'   r6   r;   rL   rO   r   r   r   r   r      s   
r   __main__)	ZunittestZtest.supportr   r   r   ZTestCaser   r	   mainr   r   r   r   <module>   s   
c