B
    u9a¼  ã               @   s.   d dl Z G dd„ de jƒZedkr*e  ¡  dS )é    Nc               @   sD   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dS )ÚAugAssignTestc             C   sd   d}|d7 }|d9 }|dC }|d8 }|d }|d; }|dM }|dO }|dN }|d }|   |d¡ d S )Né   é   é   é   é   g      @)ÚassertEqual)ÚselfÚx© r   ú$/usr/lib/python3.7/test_augassign.pyÚ	testBasic   s    zAugAssignTest.testBasicc             C   s   |   ttddd¡ d S )Nz	x, b += 3z<test>Úexec)ÚassertRaisesÚSyntaxErrorÚcompile)r	   r   r   r   Útest_with_unpacking   s    z!AugAssignTest.test_with_unpackingc             C   sº   dg}|d  d7  < |d  d9  < |d  dC  < |d  d8  < |d  d  < |d  d;  < |d  dM  < |d  dO  < |d  dN  < |d  d  < |   |d d¡ d S )Nr   r   r   r   r   r   g      @)r   )r	   r
   r   r   r   Ú
testInList   s    zAugAssignTest.testInListc             C   s¼   ddi}|d  d7  < |d  d9  < |d  dC  < |d  d8  < |d  d  < |d  d;  < |d  dM  < |d  dO  < |d  dN  < |d  d  < |   |d d¡ d S )Nr   r   r   r   r   r   g      @)r   )r	   r
   r   r   r   Ú
testInDict&   s    zAugAssignTest.testInDictc             C   s˜   ddg}|ddg7 }|d9 }|   |ddddddddg¡ dddg}|}|dd…  d9  < |dd…  dg7  < |   |dddddg¡ |  ||k¡ d S )Nr   r   r   é   )r   Ú
assertTrue)r	   r
   Úyr   r   r   ÚtestSequences4   s    
zAugAssignTest.testSequencesc          	      s  G ‡ fdd„dƒ‰ G dd„ dˆ ƒ}G ‡fdd„dˆ ƒ‰G dd„ dˆƒ}ˆ d	ƒ}|}|d
7 }|   |ˆ ¡ |  ||k	¡ |  |jd¡ |dƒ}|}|d
7 }|  ||k¡ |  |jd¡ ˆdƒ}|}|d
7 }|   |ˆ¡ |  ||k	¡ |  |jd¡ |dƒ}|  t¡ |d
7 }W d Q R X d S )Nc                   s(   e Zd Zdd„ Zdd„ Z‡ fdd„ZdS )z2AugAssignTest.testCustomMethods1.<locals>.aug_testc             S   s
   || _ d S )N)Úval)r	   Úvaluer   r   r   Ú__init__F   s    z;AugAssignTest.testCustomMethods1.<locals>.aug_test.__init__c             S   s
   | j | S )N)r   )r	   r   r   r   r   Ú__radd__H   s    z;AugAssignTest.testCustomMethods1.<locals>.aug_test.__radd__c                s   ˆ | j | ƒS )N)r   )r	   r   )Úaug_testr   r   Ú__add__J   s    z:AugAssignTest.testCustomMethods1.<locals>.aug_test.__add__N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   )r   r   r   r   E   s   r   c               @   s   e Zd Zdd„ ZdS )z3AugAssignTest.testCustomMethods1.<locals>.aug_test2c             S   s   | j | | _ | S )N)r   )r	   r   r   r   r   Ú__iadd__N   s    z<AugAssignTest.testCustomMethods1.<locals>.aug_test2.__iadd__N)r   r    r!   r"   r   r   r   r   Ú	aug_test2M   s   r#   c                   s   e Zd Z‡ fdd„ZdS )z3AugAssignTest.testCustomMethods1.<locals>.aug_test3c                s   ˆ | j | ƒS )N)r   )r	   r   )Ú	aug_test3r   r   r"   S   s    z<AugAssignTest.testCustomMethods1.<locals>.aug_test3.__iadd__N)r   r    r!   r"   r   )r$   r   r   r$   R   s   r$   c               @   s   e Zd ZdZdZdS )z3AugAssignTest.testCustomMethods1.<locals>.aug_test4z+Blocks inheritance, and fallback to __add__N)r   r    r!   Ú__doc__r"   r   r   r   r   Ú	aug_test4V   s   r&   r   é
   é   r   é   r   é   r   )ZassertIsInstancer   r   r   r   Ú	TypeError)r	   r#   r&   r
   r   r   )r   r$   r   ÚtestCustomMethods1C   s0    z AugAssignTest.testCustomMethods1c                sh  g ‰ G ‡ fdd„dƒ}|ƒ }|d  d|  |d7 }|d  d|  |d8 }|d  d|  |d9 }|d  d|  |d }|d  d|  |d }|d  d|  |d }|d  d|  |d; }|d  d|  |dC }|dB  d|B  |dO }|d@  d|@  |dM }|dA  d|A  |dN }|d?  d|?  |dL }|d>  d|>  |dK }|   ˆ d ¡ ¡ d S )Nc                   sà  e Zd Z‡ fdd„Z‡ fdd„Z‡ fdd„Z‡ fdd„Z‡ fd	d
„Z‡ fdd„Z‡ fdd„Z	‡ fdd„Z
‡ fdd„Z‡ fdd„Z‡ fdd„Z‡ fdd„Z‡ fdd„Z‡ fdd„Z‡ fdd„Z‡ fdd „Z‡ fd!d"„Z‡ fd#d$„Z‡ fd%d&„Z‡ fd'd(„Z‡ fd)d*„Z‡ fd+d,„Z‡ fd-d.„Z‡ fd/d0„Z‡ fd1d2„Z‡ fd3d4„Z‡ fd5d6„Z‡ fd7d8„Z‡ fd9d:„Z‡ fd;d<„Z ‡ fd=d>„Z!‡ fd?d@„Z"‡ fdAdB„Z#‡ fdCdD„Z$‡ fdEdF„Z%‡ fdGdH„Z&‡ fdIdJ„Z'‡ fdKdL„Z(‡ fdMdN„Z)dOS )Pz1AugAssignTest.testCustomMethods2.<locals>.testallc                s   ˆ   d¡ d S )Nz__add__ called)Úappend)r	   r   )Úoutputr   r   r   z   s    z9AugAssignTest.testCustomMethods2.<locals>.testall.__add__c                s   ˆ   d¡ d S )Nz__radd__ called)r-   )r	   r   )r.   r   r   r   |   s    z:AugAssignTest.testCustomMethods2.<locals>.testall.__radd__c                s   ˆ   d¡ | S )Nz__iadd__ called)r-   )r	   r   )r.   r   r   r"   ~   s    
z:AugAssignTest.testCustomMethods2.<locals>.testall.__iadd__c                s   ˆ   d¡ d S )Nz__sub__ called)r-   )r	   r   )r.   r   r   Ú__sub__‚   s    z9AugAssignTest.testCustomMethods2.<locals>.testall.__sub__c                s   ˆ   d¡ d S )Nz__rsub__ called)r-   )r	   r   )r.   r   r   Ú__rsub__„   s    z:AugAssignTest.testCustomMethods2.<locals>.testall.__rsub__c                s   ˆ   d¡ | S )Nz__isub__ called)r-   )r	   r   )r.   r   r   Ú__isub__†   s    
z:AugAssignTest.testCustomMethods2.<locals>.testall.__isub__c                s   ˆ   d¡ d S )Nz__mul__ called)r-   )r	   r   )r.   r   r   Ú__mul__Š   s    z9AugAssignTest.testCustomMethods2.<locals>.testall.__mul__c                s   ˆ   d¡ d S )Nz__rmul__ called)r-   )r	   r   )r.   r   r   Ú__rmul__Œ   s    z:AugAssignTest.testCustomMethods2.<locals>.testall.__rmul__c                s   ˆ   d¡ | S )Nz__imul__ called)r-   )r	   r   )r.   r   r   Ú__imul__Ž   s    
z:AugAssignTest.testCustomMethods2.<locals>.testall.__imul__c                s   ˆ   d¡ d S )Nz__matmul__ called)r-   )r	   r   )r.   r   r   Ú
__matmul__’   s    z<AugAssignTest.testCustomMethods2.<locals>.testall.__matmul__c                s   ˆ   d¡ d S )Nz__rmatmul__ called)r-   )r	   r   )r.   r   r   Ú__rmatmul__”   s    z=AugAssignTest.testCustomMethods2.<locals>.testall.__rmatmul__c                s   ˆ   d¡ | S )Nz__imatmul__ called)r-   )r	   r   )r.   r   r   Ú__imatmul__–   s    
z=AugAssignTest.testCustomMethods2.<locals>.testall.__imatmul__c                s   ˆ   d¡ | S )Nz__floordiv__ called)r-   )r	   r   )r.   r   r   Ú__floordiv__š   s    
z>AugAssignTest.testCustomMethods2.<locals>.testall.__floordiv__c                s   ˆ   d¡ | S )Nz__ifloordiv__ called)r-   )r	   r   )r.   r   r   Ú__ifloordiv__   s    
z?AugAssignTest.testCustomMethods2.<locals>.testall.__ifloordiv__c                s   ˆ   d¡ | S )Nz__rfloordiv__ called)r-   )r	   r   )r.   r   r   Ú__rfloordiv__    s    
z?AugAssignTest.testCustomMethods2.<locals>.testall.__rfloordiv__c                s   ˆ   d¡ | S )Nz__truediv__ called)r-   )r	   r   )r.   r   r   Ú__truediv__¤   s    
z=AugAssignTest.testCustomMethods2.<locals>.testall.__truediv__c                s   ˆ   d¡ | S )Nz__rtruediv__ called)r-   )r	   r   )r.   r   r   Ú__rtruediv__§   s    
z>AugAssignTest.testCustomMethods2.<locals>.testall.__rtruediv__c                s   ˆ   d¡ | S )Nz__itruediv__ called)r-   )r	   r   )r.   r   r   Ú__itruediv__ª   s    
z>AugAssignTest.testCustomMethods2.<locals>.testall.__itruediv__c                s   ˆ   d¡ d S )Nz__mod__ called)r-   )r	   r   )r.   r   r   Ú__mod__®   s    z9AugAssignTest.testCustomMethods2.<locals>.testall.__mod__c                s   ˆ   d¡ d S )Nz__rmod__ called)r-   )r	   r   )r.   r   r   Ú__rmod__°   s    z:AugAssignTest.testCustomMethods2.<locals>.testall.__rmod__c                s   ˆ   d¡ | S )Nz__imod__ called)r-   )r	   r   )r.   r   r   Ú__imod__²   s    
z:AugAssignTest.testCustomMethods2.<locals>.testall.__imod__c                s   ˆ   d¡ d S )Nz__pow__ called)r-   )r	   r   )r.   r   r   Ú__pow__¶   s    z9AugAssignTest.testCustomMethods2.<locals>.testall.__pow__c                s   ˆ   d¡ d S )Nz__rpow__ called)r-   )r	   r   )r.   r   r   Ú__rpow__¸   s    z:AugAssignTest.testCustomMethods2.<locals>.testall.__rpow__c                s   ˆ   d¡ | S )Nz__ipow__ called)r-   )r	   r   )r.   r   r   Ú__ipow__º   s    
z:AugAssignTest.testCustomMethods2.<locals>.testall.__ipow__c                s   ˆ   d¡ d S )Nz__or__ called)r-   )r	   r   )r.   r   r   Ú__or__¾   s    z8AugAssignTest.testCustomMethods2.<locals>.testall.__or__c                s   ˆ   d¡ d S )Nz__ror__ called)r-   )r	   r   )r.   r   r   Ú__ror__À   s    z9AugAssignTest.testCustomMethods2.<locals>.testall.__ror__c                s   ˆ   d¡ | S )Nz__ior__ called)r-   )r	   r   )r.   r   r   Ú__ior__Â   s    
z9AugAssignTest.testCustomMethods2.<locals>.testall.__ior__c                s   ˆ   d¡ d S )Nz__and__ called)r-   )r	   r   )r.   r   r   Ú__and__Æ   s    z9AugAssignTest.testCustomMethods2.<locals>.testall.__and__c                s   ˆ   d¡ d S )Nz__rand__ called)r-   )r	   r   )r.   r   r   Ú__rand__È   s    z:AugAssignTest.testCustomMethods2.<locals>.testall.__rand__c                s   ˆ   d¡ | S )Nz__iand__ called)r-   )r	   r   )r.   r   r   Ú__iand__Ê   s    
z:AugAssignTest.testCustomMethods2.<locals>.testall.__iand__c                s   ˆ   d¡ d S )Nz__xor__ called)r-   )r	   r   )r.   r   r   Ú__xor__Î   s    z9AugAssignTest.testCustomMethods2.<locals>.testall.__xor__c                s   ˆ   d¡ d S )Nz__rxor__ called)r-   )r	   r   )r.   r   r   Ú__rxor__Ð   s    z:AugAssignTest.testCustomMethods2.<locals>.testall.__rxor__c                s   ˆ   d¡ | S )Nz__ixor__ called)r-   )r	   r   )r.   r   r   Ú__ixor__Ò   s    
z:AugAssignTest.testCustomMethods2.<locals>.testall.__ixor__c                s   ˆ   d¡ d S )Nz__rshift__ called)r-   )r	   r   )r.   r   r   Ú
__rshift__Ö   s    z<AugAssignTest.testCustomMethods2.<locals>.testall.__rshift__c                s   ˆ   d¡ d S )Nz__rrshift__ called)r-   )r	   r   )r.   r   r   Ú__rrshift__Ø   s    z=AugAssignTest.testCustomMethods2.<locals>.testall.__rrshift__c                s   ˆ   d¡ | S )Nz__irshift__ called)r-   )r	   r   )r.   r   r   Ú__irshift__Ú   s    
z=AugAssignTest.testCustomMethods2.<locals>.testall.__irshift__c                s   ˆ   d¡ d S )Nz__lshift__ called)r-   )r	   r   )r.   r   r   Ú
__lshift__Þ   s    z<AugAssignTest.testCustomMethods2.<locals>.testall.__lshift__c                s   ˆ   d¡ d S )Nz__rlshift__ called)r-   )r	   r   )r.   r   r   Ú__rlshift__à   s    z=AugAssignTest.testCustomMethods2.<locals>.testall.__rlshift__c                s   ˆ   d¡ | S )Nz__ilshift__ called)r-   )r	   r   )r.   r   r   Ú__ilshift__â   s    
z=AugAssignTest.testCustomMethods2.<locals>.testall.__ilshift__N)*r   r    r!   r   r   r"   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   r   )r.   r   r   Útestally   sN   rS   r   a–  __add__ called
__radd__ called
__iadd__ called
__sub__ called
__rsub__ called
__isub__ called
__mul__ called
__rmul__ called
__imul__ called
__matmul__ called
__rmatmul__ called
__imatmul__ called
__truediv__ called
__rtruediv__ called
__itruediv__ called
__floordiv__ called
__rfloordiv__ called
__ifloordiv__ called
__mod__ called
__rmod__ called
__imod__ called
__pow__ called
__rpow__ called
__ipow__ called
__or__ called
__ror__ called
__ior__ called
__and__ called
__rand__ called
__iand__ called
__xor__ called
__rxor__ called
__ixor__ called
__rshift__ called
__rrshift__ called
__irshift__ called
__lshift__ called
__rlshift__ called
__ilshift__ called
)r   Ú
splitlines)Z	test_selfrS   r
   r   )r.   r   ÚtestCustomMethods2v   sX    m(z AugAssignTest.testCustomMethods2N)
r   r    r!   r   r   r   r   r   r,   rU   r   r   r   r   r      s   3r   Ú__main__)ZunittestZTestCaser   r   Úmainr   r   r   r   Ú<module>   s
     A