o
    ¯b©  ã                   @   s8   d Z ddlZddlmZ ddlmZ G dd„ deƒZdS )z&
Tests for twisted.internet.glibbase.
é    N)ÚensureNotImported)ÚTestCasec                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚEnsureNotImportedTestszQ
    L{ensureNotImported} protects against unwanted past and future imports.
    c                 C   s@   i }|   td|¡ tddgdg d¢d� |  |ddddœ¡ dS )zÁ
        If the specified modules have never been imported, and import
        prevention is requested, L{ensureNotImported} makes sure they will not
        be imported in the future.
        ÚmodulesÚm1Úm2ú
A message.)r   r   Úm3©ÚpreventImportsN©ÚpatchÚsysr   ÚassertEqual©Úselfr   © r   úE/usr/lib/python3/dist-packages/twisted/internet/test/test_glibbase.pyÚtest_ensureWhenNotImported   s   z1EnsureNotImportedTests.test_ensureWhenNotImportedc                 C   s0   i }|   td|¡ tddgdƒ |  |i ¡ dS )z˜
        If the specified modules have never been imported, and import
        prevention is not requested, L{ensureNotImported} has no effect.
        r   r   r   r   Nr   r   r   r   r   Ú%test_ensureWhenNotImportedDontPrevent   s   z<EnsureNotImportedTests.test_ensureWhenNotImportedDontPreventc                 C   sB   ddi}|   td|¡ tddgdddgd� |  |dddœ¡ dS )z†
        If the specified modules have been set to L{None} in C{sys.modules},
        L{ensureNotImported} does not complain.
        r   Nr   r   r   r
   )r   r   r   r   r   r   r   Útest_ensureWhenFailedToImport)   s   z4EnsureNotImportedTests.test_ensureWhenFailedToImportc                 C   sZ   t ƒ }d|i}|  td|¡ | jttddgdddgd�}|  |d|i¡ |  |jd¡ dS )z�
        If one of the specified modules has been previously imported,
        L{ensureNotImported} raises an exception.
        r   r   r   r   r
   )r   N)Úobjectr   r   ÚassertRaisesÚImportErrorr   r   Úargs)r   Úmoduler   Úer   r   r   Útest_ensureFailsWhenImported3   s   ûz3EnsureNotImportedTests.test_ensureFailsWhenImportedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r      s    

r   )r!   r   Útwisted.internet._glibbaser   Útwisted.trial.unittestr   r   r   r   r   r   Ú<module>   s
   