o
    ¯bu	  ã                   @   s   G d d„ dƒZ dS )c                   @   sb   e Zd ZdZdZddd„Zdd„ Zded	efd
d„Z	ded	efdd„Z
dd„ Zdd„ Zdd„ ZdS )ÚCounterzø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

    é    Nc                 C   s   || _ || _d S )N)Ú_countÚmaxval)ÚselfÚinitialValuer   © r   ú@/usr/lib/python3/dist-packages/twisted/trial/test/mockdoctest.pyÚ__init__   s   
zCounter.__init__c                 C   s4   | j dur| j| | j krtdƒ‚|  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__r   Úreturnc                 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 )zXinequality 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   ÚincrF   s   zCounter.incrc                 C   s   | j S )zlreturn this counter's value

        >>> c = Counter(555)
        >>> c.value() == 555
        True
        r   r   r   r   r   ÚvalueY   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   ÚunexpectedExceptionb   s    zCounter.unexpectedException)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r	   r   ÚobjectÚboolr   r   r   r   r   r   r   r   r   r      s    
		r   N)r   r   r   r   r   Ú<module>   s   