U
    gj                     @  s   d dl mZ d dlmZmZ d dlmZmZ ddlm	Z	 ddl
mZmZ erpd dlmZmZ d dlmZ ed	Zed
ZdddddZdS )    )annotations)partialwraps)TYPE_CHECKINGTypeVar   )_core)Clock
Instrument)	AwaitableCallable)	ParamSpecArgsTRetTz Callable[ArgsT, Awaitable[RetT]]zCallable[ArgsT, RetT])fnreturnc                   s"   t  dddd fdd}|S )aN  Converts an async test function to be synchronous, running via Trio.

    Usage::

        @trio_test
        async def test_whatever():
            await ...

    If a pytest fixture is passed in that subclasses the :class:`~trio.abc.Clock` or
    :class:`~trio.abc.Instrument` ABCs, then those are passed to :meth:`trio.run()`.
    z
ArgsT.argszArgsT.kwargsr   )argskwargsr   c                    sl   d}dd |  D }|s d }nt|dkr6|d }ntddd |  D }tjt f| |||dS )	NTc                 S  s   g | ]}t |tr|qS  )
isinstancer	   ).0cr   r   ;/tmp/pip-unpacked-wheel-ks04xdmi/trio/testing/_trio_test.py
<listcomp>$   s     
 z.trio_test.<locals>.wrapper.<locals>.<listcomp>   r   z too many clocks spoil the broth!c                 S  s   g | ]}t |tr|qS r   )r   r
   )r   ir   r   r   r   +   s     
 )clockinstruments)valueslen
ValueErrorr   runr   )r   r   Z__tracebackhide__Zclocksr   r   r   r   r   wrapper!   s    
ztrio_test.<locals>.wrapper)r   )r   r#   r   r"   r   	trio_test   s    r$   N)
__future__r   	functoolsr   r   typingr   r    r   abcr	   r
   collections.abcr   r   Ztyping_extensionsr   r   r   r$   r   r   r   r   <module>   s   