Uploaded Test files
This commit is contained in:
parent
f584ad9d97
commit
2e81cb7d99
16627 changed files with 2065359 additions and 102444 deletions
36
venv/Lib/site-packages/async_generator/_tests/conftest.py
Normal file
36
venv/Lib/site-packages/async_generator/_tests/conftest.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
import pytest
|
||||
from functools import wraps, partial
|
||||
import inspect
|
||||
import types
|
||||
|
||||
|
||||
@types.coroutine
|
||||
def mock_sleep():
|
||||
yield "mock_sleep"
|
||||
|
||||
|
||||
# Wrap any 'async def' tests so that they get automatically iterated.
|
||||
# We used to use pytest-asyncio as a convenient way to do this, but nowadays
|
||||
# pytest-asyncio uses us! In addition to it being generally bad for our test
|
||||
# infrastructure to depend on the code-under-test, this totally messes up
|
||||
# coverage info because depending on pytest's plugin load order, we might get
|
||||
# imported before pytest-cov can be loaded and start gathering coverage.
|
||||
@pytest.hookimpl(tryfirst=True)
|
||||
def pytest_pyfunc_call(pyfuncitem):
|
||||
if inspect.iscoroutinefunction(pyfuncitem.obj):
|
||||
fn = pyfuncitem.obj
|
||||
|
||||
@wraps(fn)
|
||||
def wrapper(**kwargs):
|
||||
coro = fn(**kwargs)
|
||||
try:
|
||||
while True:
|
||||
value = coro.send(None)
|
||||
if value != "mock_sleep": # pragma: no cover
|
||||
raise RuntimeError(
|
||||
"coroutine runner confused: {!r}".format(value)
|
||||
)
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
pyfuncitem.obj = wrapper
|
Loading…
Add table
Add a link
Reference in a new issue