o
    i                     @   s|   d dl Z d dlmZ d dlZd dlZd dlmZmZ edd Zdd Z	dd	 Z
d
d Zejj dd Zejj dd ZdS )    N)	MagicMock)run_hookrun_syncc                      s   t dI d H  dS )Ng{Gz?*   )asynciosleep r   r   S/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/nbclient/tests/test_util.pysome_async_function
   s   r
   c                  C   s6   dd } t  }t | ||  }||u sJ d S )Nc                      s   t  dksJ t S Nr   )r
   r   get_running_loopr   r   r   r	   _test   s   z7test_nested_asyncio_with_existing_ioloop.<locals>._test)r   new_event_loopset_event_looprun_until_complete)r   loop
event_loopr   r   r	   (test_nested_asyncio_with_existing_ioloop   s
   
r   c                   C   s   t d  t dksJ d S r   )r   r   r
   r   r   r   r	   "test_nested_asyncio_with_no_ioloop   s   
r   c                     sN   t t   tjj   fddfddfdd}  |  d S )Nc                     s0   t t d}  | dd  | I d H  dS )Ng?c                 S   s   |   S N)result)fr   r   r	   <lambda>)   s    zOtest_nested_asyncio_with_tornado.<locals>.some_async_function.<locals>.<lambda>r   )r   ensure_futurer   
add_future)future)ioloopr   r	   r
   &   s
   
z=test_nested_asyncio_with_tornado.<locals>.some_async_functionc                      s
   t   S r   )r   r   )r
   r   r	   some_sync_function-   s   
z<test_nested_asyncio_with_tornado.<locals>.some_sync_functionc                      s(     I d H dksJ  dksJ d S r   r   r   )r
   r   r   r	   run0   s   z-test_nested_asyncio_with_tornado.<locals>.run)r   r   r   tornador   IOLoopcurrentr   )r   r   )r   r
   r   r	    test_nested_asyncio_with_tornado    s   r"   c                     s(   t  } t| I d H  | jdksJ d S )N   )r   r   
call_count)r   r   r   r	   test_run_hook_sync8   s   r%   c                     s.   t t d} t| I d H  | jdksJ d S )N)return_valuer#   )r   r
   r   r$   )hookr   r   r	   test_run_hook_async?   s   r(   )r   unittest.mockr   pytestr   nbclient.utilr   r   r
   r   r   r"   markr%   r(   r   r   r   r	   <module>   s    

