U
    
W[U
  ã                   @   s$   d dl mZmZ G dd„ deƒZdS )é    )ÚdivisionÚabsolute_importc                   @   sN   e Zd ZdZdZddd„Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚCountera9  a simple counter object for testing trial's doctest support

         >>> c = Counter()
         >>> c.value()
         0
         >>> c += 3
         >>> c.value()
         3
         >>> c.incr()
         >>> c.value() == 4
         True
         >>> c == 4
         True
         >>> c != 9
         True

    r   Nc                 C   s   || _ || _d S )N)Ú_countÚmaxval)ÚselfZinitialValuer   © r   ú@/usr/lib/python3/dist-packages/twisted/trial/test/mockdoctest.pyÚ__init__   s    zCounter.__init__c                 C   s6   | j dk	r$| j| | j kr$tdƒ‚n|  j|7  _| S )z—add other to my value and return self

             >>> c = Counter(100)
             >>> c += 333
             >>> c == 433
             True
        Nzsorry, counter got too big)r   r   Ú
ValueError©r   Úotherr   r   r	   Ú__iadd__    s    
zCounter.__iadd__c                 C   s
   | j |kS )zðequality operator, compare other to my value()

           >>> c = Counter()
           >>> c == 0
           True
           >>> c += 10
           >>> c.incr()
           >>> c == 10   # fail this test on purpose
           True

        ©r   r   r   r   r	   Ú__eq__.   s    zCounter.__eq__c                 C   s   |   |¡ S )zginequality operator

             >>> c = Counter()
             >>> c != 10
             True
        )r   r   r   r   r	   Ú__ne__<   s    zCounter.__ne__c                 C   s   |   d¡ dS )a{  increment my value by 1

             >>> from twisted.trial.test.mockdoctest import Counter
             >>> c = Counter(10, 11)
             >>> c.incr()
             >>> c.value() == 11
             True
             >>> c.incr()
             Traceback (most recent call last):
               File "<stdin>", line 1, in ?
               File "twisted/trial/test/mockdoctest.py", line 51, in incr
                 self.__iadd__(1)
               File "twisted/trial/test/mockdoctest.py", line 39, in __iadd__
                 raise ValueError, "sorry, counter got too big"
             ValueError: sorry, counter got too big
        é   N)r   ©r   r   r   r	   ÚincrE   s    zCounter.incrc                 C   s   | j S )z{return this counter's value

             >>> c = Counter(555)
             >>> c.value() == 555
             True
        r   r   r   r   r	   ÚvalueX   s    zCounter.valuec                 C   s   dS )zui will raise an unexpected exception...
        ... *CAUSE THAT'S THE KINDA GUY I AM*

              >>> 1/0
        Nr   r   r   r   r	   ÚunexpectedExceptiona   s    zCounter.unexpectedException)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r
   r   r   r   r   r   r   r   r   r   r	   r      s   
		r   N)Z
__future__r   r   Úobjectr   r   r   r   r	   Ú<module>   s   