o
    ¯b¸  ã                   @   s0   d Z ddlmZ ddlmZ G dd„ deƒZdS )z&
Tests for L{twisted.python.context}.
é    )Úcontext)ÚSynchronousTestCasec                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚContextTestszH
    Tests for the module-scope APIs for L{twisted.python.context}.
    c                 C   s   |   t d¡¡ dS )zt
        Arbitrary keys which have not been set in the context have an associated
        value of L{None}.
        ÚxN)ÚassertIsNoner   Úget©Úself© r
   ú;/usr/lib/python3/dist-packages/twisted/test/test_context.pyÚtest_notPresentIfNotSet   s   z$ContextTests.test_notPresentIfNotSetc                 C   s    |   t dditjd¡d¡ dS )z•
        Values may be associated with keys by passing them in a dictionary as
        the first argument to L{twisted.python.context.call}.
        r   ÚyN)ÚassertEqualr   Úcallr   r   r
   r
   r   Útest_setByCall   s    zContextTests.test_setByCallc                 C   s(   t  ddidd„ ¡ |  t  d¡¡ dS )zŸ
        After a L{twisted.python.context.call} completes, keys specified in the
        call are no longer associated with the values from that call.
        r   r   c                   S   s   d S )Nr
   r
   r
   r
   r   Ú<lambda>%   s    z2ContextTests.test_unsetAfterCall.<locals>.<lambda>N)r   r   r   r   r   r
   r
   r   Útest_unsetAfterCall    s   z ContextTests.test_unsetAfterCallc                 C   s:   t ƒ }|  tjj|d¡ t |d¡ |  dt |¡¡ dS )zy
        A default value may be set for a key in the context using
        L{twisted.python.context.setDefault}.
        Nr   )ÚobjectÚ
addCleanupr   ÚdefaultContextDictÚpopÚ
setDefaultr   r   )r	   Úkeyr
   r
   r   Útest_setDefault(   s   zContextTests.test_setDefaultN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r
   r
   r
   r   r      s    r   N)r   Útwisted.pythonr   Útwisted.trial.unittestr   r   r
   r
   r
   r   Ú<module>   s   