ref: Add ruff rules for bugbear (B) (#3983)
Add ruff rules for bugbear (B)
This commit is contained in:
parent
06eebb5ca8
commit
7e3d470845
86 changed files with 267 additions and 230 deletions
|
|
@ -11,6 +11,9 @@ from typing import TYPE_CHECKING
|
|||
|
||||
import orjson
|
||||
import pytest
|
||||
from loguru import logger
|
||||
from pytest import LogCaptureFixture
|
||||
|
||||
from base.langflow.components.inputs.ChatInput import ChatInput
|
||||
from dotenv import load_dotenv
|
||||
from fastapi.testclient import TestClient
|
||||
|
|
@ -79,6 +82,19 @@ def get_text():
|
|||
assert path.exists(), f"File {path} does not exist. Available files: {list(data_path.iterdir())}"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def caplog(caplog: LogCaptureFixture):
|
||||
handler_id = logger.add(
|
||||
caplog.handler,
|
||||
format="{message}",
|
||||
level=0,
|
||||
filter=lambda record: record["level"].no >= caplog.handler.level,
|
||||
enqueue=False, # Set to 'True' if your test is spawning child processes.
|
||||
)
|
||||
yield caplog
|
||||
logger.remove(handler_id)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
async def async_client() -> AsyncGenerator:
|
||||
from langflow.main import create_app
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import logging
|
||||
from collections import deque
|
||||
|
||||
import pytest
|
||||
from pytest import LogCaptureFixture
|
||||
|
||||
from langflow.components.agents.ToolCallingAgent import ToolCallingAgentComponent
|
||||
from langflow.components.inputs.ChatInput import ChatInput
|
||||
|
|
@ -28,14 +30,16 @@ async def test_graph_not_prepared():
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_graph():
|
||||
async def test_graph(caplog: LogCaptureFixture):
|
||||
chat_input = ChatInput()
|
||||
chat_output = ChatOutput()
|
||||
graph = Graph()
|
||||
graph.add_component(chat_input)
|
||||
graph.add_component(chat_output)
|
||||
with pytest.warns(UserWarning, match="Graph has vertices but no edges"):
|
||||
caplog.clear()
|
||||
with caplog.at_level(logging.WARNING):
|
||||
graph.prepare()
|
||||
assert "Graph has vertices but no edges" in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue