U
    
W[                     @   sH   d Z ddlmZm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.
    )divisionabsolute_importN)TestCase)ensureNotImportedc                   @   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   sB   i }|  td| tddgddddg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.m3ZpreventImportsN)r   r	   r   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   ZassertRaisesImportErrorr   r   args)r   moduler   er   r   r   test_ensureFailsWhenImported8   s     z3EnsureNotImportedTests.test_ensureFailsWhenImportedN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r      s
   r   )
r!   Z
__future__r   r   r   Ztwisted.trial.unittestr   Ztwisted.internet._glibbaser   r   r   r   r   r   <module>   s
   