a
    Šxd  ã                   @   s8   d dl mZ ddlmZ edd„ ƒZdd„ Zdd	„ Zd
S )é    )Úcontextmanageré   )Ú_corec                 c   sŠ   d}t  ¡ }|j}|j}zJd V  | r@|j|ks8|j|kr@tdƒ‚W | s†|j|ksZ|j|kr†tdƒ‚n"| s„|j|ks||j|kr„tdƒ‚0 d S )NTz'assert_checkpoints block did not yield!z$assert_no_checkpoints block yielded!)r   Zcurrent_taskZ_cancel_pointsZ_schedule_pointsÚAssertionError)ÚexpectedÚ__tracebackhide__ZtaskZorig_cancelZorig_schedule© r   úQ/var/www/html/Ranjet/env/lib/python3.9/site-packages/trio/testing/_checkpoints.pyÚ_assert_yields_or_not   s0    ÿÿ
ÿÿ
ýÿÿr
   c                  C   s   d} t dƒS )a©  Use as a context manager to check that the code inside the ``with``
    block either exits with an exception or executes at least one
    :ref:`checkpoint <checkpoints>`.

    Raises:
      AssertionError: if no checkpoint was executed.

    Example:
      Check that :func:`trio.sleep` is a checkpoint, even if it doesn't
      block::

         with trio.testing.assert_checkpoints():
             await trio.sleep(0)

    T©r
   ©r   r   r   r	   Úassert_checkpoints   s    r   c                  C   s   d} t dƒS )aÜ  Use as a context manager to check that the code inside the ``with``
    block does not execute any :ref:`checkpoints <checkpoints>`.

    Raises:
      AssertionError: if a checkpoint was executed.

    Example:
      Synchronous code never contains any checkpoints, but we can double-check
      that::

         send_channel, receive_channel = trio.open_memory_channel(10)
         with trio.testing.assert_no_checkpoints():
             send_channel.send_nowait(None)

    TFr   r   r   r   r	   Úassert_no_checkpoints-   s    r   N)Ú
contextlibr   Ú r   r
   r   r   r   r   r   r	   Ú<module>   s
   
