o
    ACe=                     @   s   d dl Z d dlmZmZmZ d dlZd dlZddlmZ ddl	m
Z
 ddlT ddlmZ edZd	eg ee f d
edefddZdZe
dddZe
dddZe
dddZdddZdS )    N)	AwaitableCallableTypeVar   )_core)slow)*)assert_checkpointsTfexpected_durreturnc                    sZ   t  }t| I d H }t  | }t||  d||   kr&dk s)J  J | S )NgG?g      ?)timeperf_counteroutcomeZacaptureprintunwrap)r   r   startresultZdur r   =usr/lib/python3.10/site-packages/trio/_tests/test_timeouts.pycheck_takes_about   s    r   g      ?c               	      s   ddd} t | tI d H  ddd}t |tI d H  t  tdI d H  W d    n1 s0w   Y  tt . ttj	 tdI d H  W d    n1 sTw   Y  W d    d S W d    d S 1 slw   Y  d S )Nr   c                      s   t t t I d H  d S N)sleep_untilr   current_timeTARGETr   r   r   r   sleep_13   s   ztest_sleep.<locals>.sleep_1c                      s   t tI d H  d S r   )sleepr   r   r   r   r   sleep_28   s   ztest_sleep.<locals>.sleep_2r   r   N)
r   r   r	   r   
move_on_atr   r   pytestraisesZ	Cancelled)r   r   r   r   r   
test_sleep1   s   

"r#   c                     s    ddd} t | tI d H  d S )Nr   c                      >   t t tdI d H  W d    d S 1 sw   Y  d S Nd   )move_on_afterr   r   r   r   r   r   sleep_3G      
"z#test_move_on_after.<locals>.sleep_3r   )r   r   )r(   r   r   r   test_move_on_afterE   s   
r*   c                     s  ddd} t t t| tI d H  W d    n1 sw   Y  tt d  tdI d H  W d    n1 s=w   Y  ddd}t t t|tI d H  W d    n1 s_w   Y  t	d tdI d H  W d    d S 1 s{w   Y  d S )	Nr   c                      sF   t t t  tdI d H  W d    d S 1 sw   Y  d S r%   )fail_atr   r   r   r   r   r   r   r   sleep_4P   s   "ztest_fail.<locals>.sleep_4r&   r   c                      r$   r%   )
fail_afterr   r   r   r   r   r   sleep_5Z   r)   ztest_fail.<locals>.sleep_5r   )
r!   r"   ZTooSlowErrorr   r   r+   r   r   r   r-   )r,   r.   r   r   r   	test_failN   s   


"r/   c               
      s   t d} tdft| ft| ffD ] \}}tt ||I d H  W d    n1 s+w   Y  qtdft| ft| ftdft| ft	| ffD ]-\}}tt || W d    n1 s^w   Y  W d    n1 smw   Y  qEd S )Nnan)
floatr   r   r!   r"   
ValueErrorr-   r+   r'   r    )r0   Zfunvalcmr   r   r   test_timeouts_raise_value_errore   s2   
r6   r   )r   typingr   r   r   r   r!    r   Z_core._tests.tutilr   Z	_timeoutstestingr	   r
   r2   r   r   r#   r*   r/   r6   r   r   r   r   <module>   s$    "