Skip to content

Commit

Permalink
ref: Use blockbuster package (#4777)
Browse files Browse the repository at this point in the history
* Use blockbuster package

* Upgrade blockbuster to v1.1
  • Loading branch information
cbornet authored Nov 23, 2024
1 parent e61fb96 commit ab63ddd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 149 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ dev-dependencies = [
"asgi-lifespan>=2.1.0",
"pytest-github-actions-annotate-failures>=0.2.0",
"pytest-codspeed>=3.0.0",
"forbiddenfruit>=0.1.4",
"blockbuster>=1.1.0,<1.2",
]


Expand Down
144 changes: 0 additions & 144 deletions src/backend/tests/blockbuster.py

This file was deleted.

19 changes: 17 additions & 2 deletions src/backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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
Expand All @@ -34,15 +35,29 @@
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:
from langflow.services.database.service import DatabaseService


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):
Expand Down
16 changes: 14 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ab63ddd

Please sign in to comment.