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
   