o
    ŒžP]  ã                   @   s0   d dl mZmZ ddlmZ G dd„ deƒZdS )é   )Ú	AutomatonÚNoTransitioné    )ÚTestCasec                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )Ú	CoreTestszN
    Tests for Automat's (currently private, implementation detail) core.
    c                 C   sv   |   t¡ tƒ  W d  ƒ n1 sw   Y  d}d}t||d}|  |j|¡ |  |t|ƒ¡ |  |t|ƒ¡ dS )zj
        A L{NoTransition} exception describes the state and input symbol
        that caused it.
        Nzcurrent-stateztransitionless-symbol)ÚstateÚsymbol)ÚassertRaisesÚ	TypeErrorr   ÚassertIsr   ÚassertInÚstr)Úselfr   r   ÚnoTransitionException© r   ú9/usr/lib/python3/dist-packages/automat/_test/test_core.pyÚtest_NoTransition   s   ÿzCoreTests.test_NoTransitionc                 C   s   t ƒ }|  t|jdd¡ dS )zx
        L{Automaton.outputForInput} raises L{NoTransition} if no
        transition for that input is defined.
        zno-statez	no-symbolN)r   r	   r   ÚoutputForInput©r   Úar   r   r   Útest_noOutputForInput   s   
ÿzCoreTests.test_noOutputForInputc                 C   sn   t ƒ }| ddddg¡ |  | ¡ dh¡ |  | ¡ dh¡ |  | dd¡ddgf¡ |  | ¡ ddh¡ dS )a  
        L{Automaton.addTransition} adds its input symbol to
        L{Automaton.inputAlphabet}, all its outputs to
        L{Automaton.outputAlphabet}, and causes L{Automaton.outputForInput} to
        start returning the new state and output symbols.
        Ú	beginningÚbeginÚendingÚendN)r   ÚaddTransitionÚassertEqualÚinputAlphabetÚoutputAlphabetr   Ústatesr   r   r   r   Útest_oneTransition(   s   ÿzCoreTests.test_oneTransitionc                 C   s\   t ƒ }d}|  t|jddd|¡ |  | ¡ ¡ |  | ¡ ¡ |  | ¡ ¡ |  | ¡ ¡ dS )z
        L{Automaton.addTransition} raises a TypeError when given outputs
        that aren't iterable and doesn't add any transitions.
        é   Ú	fromStateÚ	viaSymbolÚtoStateN)	r   r	   r
   r   ÚassertFalser   r   r   ÚallTransitions)r   r   ÚnonIterableOutputsr   r   r   Ú%test_oneTransition_nonIterableOutputs8   s   ýz/CoreTests.test_oneTransition_nonIterableOutputsc                 C   sP   t ƒ }d|_|  |jd¡ |  t¡ d|_W d  ƒ dS 1 s!w   Y  dS )z˜
        L{Automaton.initialState} is a descriptor that sets the initial
        state if it's not yet set, and raises L{ValueError} if it is.

        za statezanother stateN)r   ÚinitialStater   r	   Ú
ValueErrorr   r   r   r   Útest_initialStateI   s   "ÿzCoreTests.test_initialStateN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r    r(   r+   r   r   r   r   r      s    
r   N)Ú_corer   r   Úunittestr   r   r   r   r   r   Ú<module>   s   