o
    >hC                     @   sD   d Z ddlmZ ddlmZ ddlmZmZmZ G dd deZ	dS )	z(
Tests for L{twisted._threads._memory}.
    )verifyObject)SynchronousTestCase   )AlreadyQuitIWorkercreateMemoryWorkerc                   @   s.   e Zd ZdZd
ddZd
ddZd
dd	ZdS )MemoryWorkerTestsz$
    Tests for L{MemoryWorker}.
    returnNc                    s   t  \}}tt| g  | fdd | fdd |  g  | | d |  dg | | d |  ddg dS )z
        L{createMemoryWorker} creates an L{IWorker} and a callable that can
        perform work on it.  The performer returns C{True} if it accomplished
        useful work.
        c                      
     dS )N   append doner   /var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/_threads/test/test_memory.py<lambda>      
 z?MemoryWorkerTests.test_createWorkerAndPerform.<locals>.<lambda>c                      r
   )N   r   r   r   r   r   r      r   Tr   r   N)r   r   r   doassertEqualselfworker	performerr   r   r   test_createWorkerAndPerform   s   

z-MemoryWorkerTests.test_createWorkerAndPerformc                    sr   t  \}}g  d fdd}|| |  | t|j| | t|j |  |  dg | | d dS )a  
        Calling C{quit} on the worker returned by L{createMemoryWorker} causes
        its C{do} and C{quit} methods to raise L{AlreadyQuit}; its C{perform}
        callable will start raising L{AlreadyQuit} when the work already
        provided to C{do} has been exhausted.
        r	   Nc                      s     d d S )N   r   r   r   r   r   moreWork.   s   z2MemoryWorkerTests.test_quitQuits.<locals>.moreWorkr   Fr	   N)r   r   quitassertRaisesr   r   )r   r   r   r   r   r   r   test_quitQuits$   s   

z MemoryWorkerTests.test_quitQuitsc                 C   s   t  \}}| | d dS )z
        The C{perform} callable returned by L{createMemoryWorker} will return
        no result when there's no work to do yet.  Since there is no work to
        do, the performer returns C{False}.
        FN)r   r   r   r   r   r   test_performWhenNothingToDoYet9   s   
z0MemoryWorkerTests.test_performWhenNothingToDoYetr   )__name__
__module____qualname____doc__r   r!   r"   r   r   r   r   r      s
    

r   N)
r&   zope.interface.verifyr   twisted.trial.unittestr    r   r   r   r   r   r   r   r   <module>   s
   