ref: Use blockbuster package (#4777)
* Use blockbuster package * Upgrade blockbuster to v1.1
This commit is contained in:
parent
e61fb96504
commit
ab63ddddbd
4 changed files with 32 additions and 149 deletions
|
|
@ -13,6 +13,7 @@ from uuid import UUID
|
|||
import orjson
|
||||
import pytest
|
||||
from asgi_lifespan import LifespanManager
|
||||
from blockbuster import blockbuster_ctx
|
||||
from dotenv import load_dotenv
|
||||
from fastapi.testclient import TestClient
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
|
|
@ -34,7 +35,6 @@ from sqlmodel.ext.asyncio.session import AsyncSession
|
|||
from sqlmodel.pool import StaticPool
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from tests import blockbuster
|
||||
from tests.api_keys import get_openai_api_key
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
@ -42,7 +42,22 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
load_dotenv()
|
||||
blockbuster.init()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def blockbuster():
|
||||
with blockbuster_ctx() as bb:
|
||||
for func in [
|
||||
"io.BufferedReader.read",
|
||||
"io.BufferedWriter.write",
|
||||
"io.TextIOWrapper.read",
|
||||
"io.TextIOWrapper.write",
|
||||
]:
|
||||
bb.functions[func].can_block_functions.append(("settings/service.py", {"initialize"}))
|
||||
for func in bb.functions:
|
||||
if func.startswith("sqlite3."):
|
||||
bb.functions[func].deactivate()
|
||||
yield bb
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue