Server IP : 85.214.239.14 / Your IP : 13.58.53.112 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/root/proc/2/cwd/proc/self/root/lib/python3/dist-packages/sniffio/_tests/ |
Upload File : |
import sys import pytest from .. import ( current_async_library, AsyncLibraryNotFoundError, current_async_library_cvar ) def test_basics(): with pytest.raises(AsyncLibraryNotFoundError): current_async_library() token = current_async_library_cvar.set("generic-lib") try: assert current_async_library() == "generic-lib" finally: current_async_library_cvar.reset(token) with pytest.raises(AsyncLibraryNotFoundError): current_async_library() def test_asyncio(): import asyncio with pytest.raises(AsyncLibraryNotFoundError): current_async_library() ran = [] async def this_is_asyncio(): assert current_async_library() == "asyncio" # Call it a second time to exercise the caching logic assert current_async_library() == "asyncio" ran.append(True) loop = asyncio.get_event_loop() loop.run_until_complete(this_is_asyncio()) assert ran == [True] loop.close() with pytest.raises(AsyncLibraryNotFoundError): current_async_library() @pytest.mark.skip("Debian doesn't package curio so it cannot be tested here") @pytest.mark.skipif(sys.version_info < (3, 6), reason='Curio requires 3.6+') def test_curio(): import curio with pytest.raises(AsyncLibraryNotFoundError): current_async_library() ran = [] async def this_is_curio(): assert current_async_library() == "curio" # Call it a second time to exercise the caching logic assert current_async_library() == "curio" ran.append(True) curio.run(this_is_curio) assert ran == [True] with pytest.raises(AsyncLibraryNotFoundError): current_async_library()