B
    u9aJ                 @   sX   d dl Z G dd dZG dd dZG dd dZG dd	 d	e jZed
krTe   dS )    Nc               @   s   e Zd Zdd ZdS )Emptyc             C   s   dS )Nz<Empty> )selfr   r   "/usr/lib/python3.7/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 )N)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               @   s   e Zd Zdd Zdd ZdS )Anythingc             C   s   dS )NTr   )r   r   r   r   r   r      s    zAnything.__eq__c             C   s   dS )NFr   )r   r   r   r   r   __ne__   s    zAnything.__ne__N)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   sZ   xT| j D ]J}xD| j D ]:}|| jkr,|| jks4||krB| || q| || qW qW d S )N)
candidatesset1assertEqualZassertNotEqual)r   abr   r   r   test_comparisons   s
    zComparisonTest.test_comparisonsc          	   C   sr   g }x&t dD ]}|t|d t  qW x@|D ]8}x2|D ]*}| ||kt|t|kd||f  q<W q2W 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 )Nc                   s   e Zd Z fddZdS )z2ComparisonTest.test_ne_high_priority.<locals>.Leftc                 s     d tS )NzLeft.__eq__)appendNotImplemented)args)callsr   r   r   <   s    
z9ComparisonTest.test_ne_high_priority.<locals>.Left.__eq__N)r   r   r	   r   r   )r)   r   r   Left:   s   r*   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   r   @   s    
z:ComparisonTest.test_ne_high_priority.<locals>.Right.__eq__c                 s     d tS )NzRight.__ne__)r&   r'   )r(   )r)   r   r   r   C   s    
z:ComparisonTest.test_ne_high_priority.<locals>.Right.__ne__N)r   r   r	   r   r   r   )r)   r   r   Right?   s   r+   zLeft.__eq__zRight.__ne__)assertSequenceEqual)r   r*   r+   r   )r)   r   test_ne_high_priority7   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 )Nc                   s   e Zd Z fddZdS )z1ComparisonTest.test_ne_low_priority.<locals>.Basec                 s     d tS )NzBase.__eq__)r&   r'   )r(   )r)   r   r   r   N   s    
z8ComparisonTest.test_ne_low_priority.<locals>.Base.__eq__N)r   r   r	   r   r   )r)   r   r   BaseL   s   r.   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   r   R   s    
z;ComparisonTest.test_ne_low_priority.<locals>.Derived.__eq__c                 s     d tS )NzDerived.__ne__)r&   r'   )r(   )r)   r   r   r   U   s    
z;ComparisonTest.test_ne_low_priority.<locals>.Derived.__ne__N)r   r   r	   r   r   r   )r)   r   r   DerivedQ   s   r/   zDerived.__ne__zBase.__eq__)r,   )r   r.   r/   r   )r)   r   test_ne_low_priorityI   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}x|D ]\}}  |~  fddG fddd}x$|D ]\}}||krtt|| qtW |dkr || t d n t|| t  W d Q R X q<W d S )Nr   c             S   s   | |kS )Nr   )r   r   r   r   r   <lambda>^       z6ComparisonTest.test_other_delegation.<locals>.<lambda>__lt__c             S   s   | |k S )Nr   )r   r   r   r   r   r1   _   r2   __le__c             S   s   | |kS )Nr   )r   r   r   r   r   r1   `   r2   __gt__c             S   s   | |kS )Nr   )r   r   r   r   r   r1   a   r2   __ge__c             S   s   | |kS )Nr   )r   r   r   r   r   r1   b   r2   c                 s     d d S )Nz!Unexpected operator method called)Zfail)r(   )r   r   r   
unexpectedf   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	   r   r   )r7   r   r   Ch   s   r8   F)ZsubTestsetattrr#   objectZassertRaises	TypeError)r   Zopsnamefuncr8   r   _r   )r   r7   r   test_other_delegation[   s    



z$ComparisonTest.test_other_delegationc             C   sJ   dd }|  |t  |  t | t }|  |t  |  t | d S )Nc               S   s   d S )Nr   r   r   r   r   r1   s   r2   z0ComparisonTest.test_issue_1393.<locals>.<lambda>)r   r   r:   )r   xyr   r   r   test_issue_1393r   s    zComparisonTest.test_issue_1393)r   r   r	   r
   r   r   Zset2r   r   r"   r%   r-   r0   r?   rB   r   r   r   r   r      s   
r   __main__)Zunittestr   r
   r   ZTestCaser   r   mainr   r   r   r   <module>   s   
c