mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 02:34:29 +00:00
(ci/cd) pytest event loop fixture
This commit is contained in:
parent
050c289ed1
commit
dfdd329ddf
1 changed files with 17 additions and 0 deletions
|
@ -61,6 +61,23 @@ async def wrapper_startup_event():
|
||||||
await startup_event()
|
await startup_event()
|
||||||
|
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.yield_fixture
|
||||||
|
def event_loop():
|
||||||
|
"""Create an instance of the default event loop for each test case."""
|
||||||
|
policy = asyncio.WindowsSelectorEventLoopPolicy()
|
||||||
|
res = policy.new_event_loop()
|
||||||
|
asyncio.set_event_loop(res)
|
||||||
|
res._close = res.close
|
||||||
|
res.close = lambda: None
|
||||||
|
|
||||||
|
yield res
|
||||||
|
|
||||||
|
res._close()
|
||||||
|
|
||||||
|
|
||||||
# Here you create a fixture that will be used by your tests
|
# Here you create a fixture that will be used by your tests
|
||||||
# Make sure the fixture returns TestClient(app)
|
# Make sure the fixture returns TestClient(app)
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue