a
    xd                     @   sx   d dl Z d dlZd dlZddlmZ ddlmZ ddlmZ ddl	T dd Z
d	Zed
d Zedd Zedd ZdS )    N   )slow)_core)assert_checkpoints)*c                    sV   t  }t| I d H }t  | }t||  d||   krHdk sNn J | S )NgG?g      ?)timeperf_counteroutcomeZacaptureprintunwrap)fZexpected_durstartresultZdur r   P/var/www/html/Ranjet/env/lib/python3.9/site-packages/trio/tests/test_timeouts.pycheck_takes_about   s    r   g      ?c               	      s  dd } t | tI d H  dd }t |tI d H  tt tdI d H  W d    n1 s^0    Y  t  tdI d H  W d    n1 s0    Y  tt	 J ttj
 tdI d H  W d    n1 s0    Y  W d    n1 s0    Y  d S )Nc                      s   t t t I d H  d S N)Zsleep_untilr   current_timeTARGETr   r   r   r   sleep_1.   s    ztest_sleep.<locals>.sleep_1c                      s   t tI d H  d S r   )sleepr   r   r   r   r   sleep_23   s    ztest_sleep.<locals>.sleep_2r   )r   r   pytestraises
ValueErrorr   r   Z
move_on_atr   r   Z	Cancelled)r   r   r   r   r   
test_sleep,   s    ,,r   c               	      sn   t t8 td W d    n1 s*0    Y  W d    n1 sH0    Y  dd } t| tI d H  d S )Nr   c                      s:   t t tdI d H  W d    n1 s,0    Y  d S Nd   )move_on_afterr   r   r   r   r   r   sleep_3I   s    
z#test_move_on_after.<locals>.sleep_3)r   r   r   r   r   r   )r    r   r   r   test_move_on_afterC   s
    
<r!   c               	      sR  dd } t t  t| tI d H  W d    n1 s80    Y  tt d  tdI d H  W d    n1 sv0    Y  dd }t t  t|tI d H  W d    n1 s0    Y  t	d tdI d H  W d    n1 s0    Y  t t
: t	d W d    n1 s$0    Y  W d    n1 sD0    Y  d S )Nc                      sB   t t t  tdI d H  W d    n1 s40    Y  d S r   )fail_atr   r   r   r   r   r   r   r   sleep_4R   s    ztest_fail.<locals>.sleep_4r   r   c                      s:   t t tdI d H  W d    n1 s,0    Y  d S r   )
fail_afterr   r   r   r   r   r   sleep_5\   s    
ztest_fail.<locals>.sleep_5r   )r   r   ZTooSlowErrorr   r   r"   r   r   r   r$   r   )r#   r%   r   r   r   	test_failP   s    .,.
,
r&   )r	   r   r   Z_core.tests.tutilr    r   Ztestingr   Z	_timeoutsr   r   r   r!   r&   r   r   r   r   <module>   s   

