o
    Òó·i  ã                   @   s„   d Z ddlZddlmZ ddlmZ G dd„ deƒZzddlmZ	 W n e
y-   dZY nw e	ZdZedu r8d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   Zm3©ZpreventImportsN©ÚpatchÚsysr   ÚassertEqual©Úselfr   © r   úiC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-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   )Ú	gireactorzgi reactor not availablec                   @   s   e Zd ZdZeZdd„ ZdS )ÚGlibReactorBaseTestsz•
    Tests for the private C{twisted.internet._glibbase.GlibReactorBase}
    done via the public C{twisted.internet.gireactor.PortableGIReactor}
    c                 C   s(   t jdd�}|  d| ¡ ¡ | ¡  dS )z²
        C{simulate} can be called without raising any errors when there are
        no delayed calls for the reactor and hence there is no defined sleep
        period.
        F)ZuseGtkN)r    ZPortableGIReactorZassertIsÚtimeoutZsimulate)r   Zsutr   r   r   Útest_simulateZ   s   z"GlibReactorBaseTests.test_simulateN)r   r   r   r   ÚmissingGlibReactorÚskipr#   r   r   r   r   r!   R   s    r!   )r   r   Ztwisted.internet._glibbaser   Ztwisted.trial.unittestr   r   Ztwisted.internetr    Z
_gireactorr   r$   r!   r   r   r   r   Ú<module>   s   7ÿ