From df22924b0ebaa252775a8008f39b945a568824f4 Mon Sep 17 00:00:00 2001 From: Christophe Bornet Date: Sat, 2 Nov 2024 14:46:07 +0100 Subject: [PATCH] ref: Remove useless pytest.mark.asyncio (#4364) --- .../backward_compatibility/test_starter_projects.py | 1 - .../components/assistants/test_assistants_components.py | 1 - .../integration/components/astra/test_astra_component.py | 2 -- .../integration/components/helpers/test_parse_json_data.py | 3 --- .../tests/integration/components/inputs/test_chat_input.py | 4 ---- .../tests/integration/components/inputs/test_text_input.py | 2 -- .../components/output_parsers/test_output_parser.py | 1 - .../tests/integration/components/outputs/test_chat_output.py | 4 ---- .../tests/integration/components/outputs/test_text_output.py | 3 --- .../tests/integration/components/prompts/test_prompt.py | 2 -- src/backend/tests/integration/flows/test_basic_prompting.py | 2 -- .../tests/unit/components/agents/test_agent_component.py | 1 - .../tests/unit/components/agents/test_tool_calling_agent.py | 1 - .../unit/components/prototypes/test_create_data_component.py | 1 - .../unit/components/prototypes/test_update_data_component.py | 1 - src/backend/tests/unit/events/test_event_manager.py | 4 ---- src/backend/tests/unit/graph/graph/test_base.py | 5 ----- src/backend/tests/unit/schema/test_schema_message.py | 2 -- src/backend/tests/unit/test_data_components.py | 4 ---- src/backend/tests/unit/test_database.py | 2 -- src/backend/tests/unit/test_initial_setup.py | 3 --- src/backend/tests/unit/test_process.py | 4 ---- 22 files changed, 53 deletions(-) diff --git a/src/backend/tests/integration/backward_compatibility/test_starter_projects.py b/src/backend/tests/integration/backward_compatibility/test_starter_projects.py index d2319c56d..a7e7d9059 100644 --- a/src/backend/tests/integration/backward_compatibility/test_starter_projects.py +++ b/src/backend/tests/integration/backward_compatibility/test_starter_projects.py @@ -5,7 +5,6 @@ from tests.api_keys import get_openai_api_key from tests.integration.utils import download_flow_from_github, run_json_flow -@pytest.mark.asyncio @pytest.mark.api_key_required async def test_1_0_15_basic_prompting(): api_key = get_openai_api_key() diff --git a/src/backend/tests/integration/components/assistants/test_assistants_components.py b/src/backend/tests/integration/components/assistants/test_assistants_components.py index 019711b35..d808d3de6 100644 --- a/src/backend/tests/integration/components/assistants/test_assistants_components.py +++ b/src/backend/tests/integration/components/assistants/test_assistants_components.py @@ -15,7 +15,6 @@ async def test_list_assistants(): @pytest.mark.api_key_required -@pytest.mark.asyncio async def test_create_assistants(): from langflow.components.astra_assistants import AssistantsCreateAssistant diff --git a/src/backend/tests/integration/components/astra/test_astra_component.py b/src/backend/tests/integration/components/astra/test_astra_component.py index fed8d1866..3d598a3c1 100644 --- a/src/backend/tests/integration/components/astra/test_astra_component.py +++ b/src/backend/tests/integration/components/astra/test_astra_component.py @@ -36,7 +36,6 @@ def astradb_client(): @pytest.mark.api_key_required -@pytest.mark.asyncio async def test_base(astradb_client: AstraDB): from langflow.components.embeddings import OpenAIEmbeddingsComponent @@ -65,7 +64,6 @@ async def test_base(astradb_client: AstraDB): @pytest.mark.api_key_required -@pytest.mark.asyncio async def test_astra_embeds_and_search(): application_token = get_astradb_application_token() api_endpoint = get_astradb_api_endpoint() diff --git a/src/backend/tests/integration/components/helpers/test_parse_json_data.py b/src/backend/tests/integration/components/helpers/test_parse_json_data.py index 16e01b902..d0aff47ca 100644 --- a/src/backend/tests/integration/components/helpers/test_parse_json_data.py +++ b/src/backend/tests/integration/components/helpers/test_parse_json_data.py @@ -1,4 +1,3 @@ -import pytest from langflow.components.helpers import ParseJSONDataComponent from langflow.components.inputs import ChatInput from langflow.schema import Data @@ -7,7 +6,6 @@ from tests.integration.components.mock_components import TextToData from tests.integration.utils import ComponentInputHandle, run_single_component -@pytest.mark.asyncio async def test_from_data(): outputs = await run_single_component( ParseJSONDataComponent, @@ -34,7 +32,6 @@ async def test_from_data(): assert outputs["filtered_data"] == [Data(text="2")] -@pytest.mark.asyncio async def test_from_message(): outputs = await run_single_component( ParseJSONDataComponent, diff --git a/src/backend/tests/integration/components/inputs/test_chat_input.py b/src/backend/tests/integration/components/inputs/test_chat_input.py index dd7840eef..698e8d266 100644 --- a/src/backend/tests/integration/components/inputs/test_chat_input.py +++ b/src/backend/tests/integration/components/inputs/test_chat_input.py @@ -1,4 +1,3 @@ -import pytest from langflow.components.inputs import ChatInput from langflow.memory import get_messages from langflow.schema.message import Message @@ -6,7 +5,6 @@ from langflow.schema.message import Message from tests.integration.utils import run_single_component -@pytest.mark.asyncio async def test_default(): outputs = await run_single_component(ChatInput, run_input="hello") assert isinstance(outputs["message"], Message) @@ -21,7 +19,6 @@ async def test_default(): assert outputs["message"].sender_name == "User" -@pytest.mark.asyncio async def test_sender(): outputs = await run_single_component( ChatInput, inputs={"sender": "Machine", "sender_name": "AI"}, run_input="hello" @@ -32,7 +29,6 @@ async def test_sender(): assert outputs["message"].sender_name == "AI" -@pytest.mark.asyncio async def test_do_not_store_messages(): session_id = "test-session-id" outputs = await run_single_component( diff --git a/src/backend/tests/integration/components/inputs/test_text_input.py b/src/backend/tests/integration/components/inputs/test_text_input.py index c4169c987..366868139 100644 --- a/src/backend/tests/integration/components/inputs/test_text_input.py +++ b/src/backend/tests/integration/components/inputs/test_text_input.py @@ -1,11 +1,9 @@ -import pytest from langflow.components.inputs import TextInputComponent from langflow.schema.message import Message from tests.integration.utils import run_single_component -@pytest.mark.asyncio async def test_text_input(): outputs = await run_single_component(TextInputComponent, run_input="sample text", input_type="text") assert isinstance(outputs["text"], Message) diff --git a/src/backend/tests/integration/components/output_parsers/test_output_parser.py b/src/backend/tests/integration/components/output_parsers/test_output_parser.py index 83fb487e3..619acb94a 100644 --- a/src/backend/tests/integration/components/output_parsers/test_output_parser.py +++ b/src/backend/tests/integration/components/output_parsers/test_output_parser.py @@ -8,7 +8,6 @@ from langflow.components.prompts import PromptComponent from tests.integration.utils import ComponentInputHandle, run_single_component -@pytest.mark.asyncio @pytest.mark.api_key_required async def test_csv_output_parser_openai(): format_instructions = ComponentInputHandle( diff --git a/src/backend/tests/integration/components/outputs/test_chat_output.py b/src/backend/tests/integration/components/outputs/test_chat_output.py index 27b4e4217..24fd047e2 100644 --- a/src/backend/tests/integration/components/outputs/test_chat_output.py +++ b/src/backend/tests/integration/components/outputs/test_chat_output.py @@ -1,4 +1,3 @@ -import pytest from langflow.components.outputs import ChatOutput from langflow.memory import get_messages from langflow.schema.message import Message @@ -6,7 +5,6 @@ from langflow.schema.message import Message from tests.integration.utils import run_single_component -@pytest.mark.asyncio async def test_string(): outputs = await run_single_component(ChatOutput, inputs={"input_value": "hello"}) assert isinstance(outputs["message"], Message) @@ -15,7 +13,6 @@ async def test_string(): assert outputs["message"].sender_name == "AI" -@pytest.mark.asyncio async def test_message(): outputs = await run_single_component(ChatOutput, inputs={"input_value": Message(text="hello")}) assert isinstance(outputs["message"], Message) @@ -24,7 +21,6 @@ async def test_message(): assert outputs["message"].sender_name == "AI" -@pytest.mark.asyncio async def test_do_not_store_message(): session_id = "test-session-id" outputs = await run_single_component( diff --git a/src/backend/tests/integration/components/outputs/test_text_output.py b/src/backend/tests/integration/components/outputs/test_text_output.py index 22076462e..a79977a74 100644 --- a/src/backend/tests/integration/components/outputs/test_text_output.py +++ b/src/backend/tests/integration/components/outputs/test_text_output.py @@ -1,11 +1,9 @@ -import pytest from langflow.components.outputs import TextOutputComponent from langflow.schema.message import Message from tests.integration.utils import run_single_component -@pytest.mark.asyncio async def test(): outputs = await run_single_component(TextOutputComponent, inputs={"input_value": "hello"}) assert isinstance(outputs["text"], Message) @@ -14,7 +12,6 @@ async def test(): assert outputs["text"].sender_name is None -@pytest.mark.asyncio async def test_message(): outputs = await run_single_component(TextOutputComponent, inputs={"input_value": Message(text="hello")}) assert isinstance(outputs["text"], Message) diff --git a/src/backend/tests/integration/components/prompts/test_prompt.py b/src/backend/tests/integration/components/prompts/test_prompt.py index 1f52fd3b7..41c61c93f 100644 --- a/src/backend/tests/integration/components/prompts/test_prompt.py +++ b/src/backend/tests/integration/components/prompts/test_prompt.py @@ -1,11 +1,9 @@ -import pytest from langflow.components.prompts import PromptComponent from langflow.schema.message import Message from tests.integration.utils import run_single_component -@pytest.mark.asyncio async def test(): outputs = await run_single_component(PromptComponent, inputs={"template": "test {var1}", "var1": "from the var"}) assert isinstance(outputs["prompt"], Message) diff --git a/src/backend/tests/integration/flows/test_basic_prompting.py b/src/backend/tests/integration/flows/test_basic_prompting.py index 46dac6dec..9f66e894b 100644 --- a/src/backend/tests/integration/flows/test_basic_prompting.py +++ b/src/backend/tests/integration/flows/test_basic_prompting.py @@ -1,4 +1,3 @@ -import pytest from langflow.components.inputs import ChatInput from langflow.components.outputs import ChatOutput from langflow.components.prompts import PromptComponent @@ -8,7 +7,6 @@ from langflow.schema.message import Message from tests.integration.utils import run_flow -@pytest.mark.asyncio async def test_simple_no_llm(): graph = Graph() flow_input = graph.add_component(ChatInput()) diff --git a/src/backend/tests/unit/components/agents/test_agent_component.py b/src/backend/tests/unit/components/agents/test_agent_component.py index 2d999cdbd..968abfab9 100644 --- a/src/backend/tests/unit/components/agents/test_agent_component.py +++ b/src/backend/tests/unit/components/agents/test_agent_component.py @@ -6,7 +6,6 @@ from langflow.components.tools.calculator import CalculatorToolComponent @pytest.mark.api_key_required -@pytest.mark.asyncio async def test_agent_component_with_calculator(): # Mock inputs tools = [CalculatorToolComponent().build_tool()] # Use the Calculator component as a tool diff --git a/src/backend/tests/unit/components/agents/test_tool_calling_agent.py b/src/backend/tests/unit/components/agents/test_tool_calling_agent.py index 312d29cf3..a51321429 100644 --- a/src/backend/tests/unit/components/agents/test_tool_calling_agent.py +++ b/src/backend/tests/unit/components/agents/test_tool_calling_agent.py @@ -7,7 +7,6 @@ from langflow.components.tools.calculator import CalculatorToolComponent @pytest.mark.api_key_required -@pytest.mark.asyncio async def test_tool_calling_agent_component(): tools = [CalculatorToolComponent().build_tool()] # Use the Calculator component as a tool input_value = "What is 2 + 2?" diff --git a/src/backend/tests/unit/components/prototypes/test_create_data_component.py b/src/backend/tests/unit/components/prototypes/test_create_data_component.py index 716ea9a4e..0d4a75736 100644 --- a/src/backend/tests/unit/components/prototypes/test_create_data_component.py +++ b/src/backend/tests/unit/components/prototypes/test_create_data_component.py @@ -54,7 +54,6 @@ def test_update_build_config_exceed_limit(create_data_component): create_data_component.update_build_config(build_config, 16, "number_of_fields") -@pytest.mark.asyncio async def test_build_data(create_data_component): create_data_component._attributes = { "field_1_key": {"key1": "value1"}, diff --git a/src/backend/tests/unit/components/prototypes/test_update_data_component.py b/src/backend/tests/unit/components/prototypes/test_update_data_component.py index 0eef004e9..77525f363 100644 --- a/src/backend/tests/unit/components/prototypes/test_update_data_component.py +++ b/src/backend/tests/unit/components/prototypes/test_update_data_component.py @@ -54,7 +54,6 @@ def test_update_build_config_exceed_limit(update_data_component): update_data_component.update_build_config(build_config, 16, "number_of_fields") -@pytest.mark.asyncio async def test_build_data(update_data_component): update_data_component._attributes = { "field_1_key": {"key1": "new_value1"}, diff --git a/src/backend/tests/unit/events/test_event_manager.py b/src/backend/tests/unit/events/test_event_manager.py index b02e29d2c..0fff5b252 100644 --- a/src/backend/tests/unit/events/test_event_manager.py +++ b/src/backend/tests/unit/events/test_event_manager.py @@ -37,7 +37,6 @@ class TestEventManager: assert manager.events["on_test_event"].func == manager.send_event # Sending an event with valid event_type and data using pytest-asyncio plugin - @pytest.mark.asyncio async def test_sending_event_with_valid_type_and_data_asyncio_plugin(self): async def mock_queue_put_nowait(item): await queue.put(item) @@ -96,7 +95,6 @@ class TestEventManager: manager.register_event("invalid_name", "test_type", mock_callback) # Sending an event with complex data and verifying successful event transmission - @pytest.mark.asyncio async def test_sending_event_with_complex_data(self): queue = asyncio.Queue() manager = EventManager(queue) @@ -149,7 +147,6 @@ class TestEventManager: # Verifying the uniqueness of event IDs for each event triggered using await with asyncio decorator import pytest - @pytest.mark.asyncio async def test_event_id_uniqueness_with_await(self): queue = asyncio.Queue() manager = EventManager(queue) @@ -165,7 +162,6 @@ class TestEventManager: assert event_id_1 != event_id_2 # Ensuring the queue receives the correct event data format - @pytest.mark.asyncio async def test_queue_receives_correct_event_data_format(self): async def mock_queue_put_nowait(data): pass diff --git a/src/backend/tests/unit/graph/graph/test_base.py b/src/backend/tests/unit/graph/graph/test_base.py index a434d97e5..b85b069ac 100644 --- a/src/backend/tests/unit/graph/graph/test_base.py +++ b/src/backend/tests/unit/graph/graph/test_base.py @@ -10,7 +10,6 @@ from langflow.graph import Graph from langflow.graph.graph.constants import Finish -@pytest.mark.asyncio async def test_graph_not_prepared(): chat_input = ChatInput() chat_output = ChatOutput() @@ -21,7 +20,6 @@ async def test_graph_not_prepared(): await graph.astep() -@pytest.mark.asyncio async def test_graph(caplog: pytest.LogCaptureFixture): chat_input = ChatInput() chat_output = ChatOutput() @@ -34,7 +32,6 @@ async def test_graph(caplog: pytest.LogCaptureFixture): assert "Graph has vertices but no edges" in caplog.text -@pytest.mark.asyncio async def test_graph_with_edge(): chat_input = ChatInput() chat_output = ChatOutput() @@ -55,7 +52,6 @@ async def test_graph_with_edge(): assert graph.edges[0].target_id == output_id -@pytest.mark.asyncio async def test_graph_functional(): chat_input = ChatInput(_id="chat_input") chat_output = ChatOutput(input_value="test", _id="chat_output") @@ -71,7 +67,6 @@ async def test_graph_functional(): assert graph.edges[0].target_id == "chat_output" -@pytest.mark.asyncio async def test_graph_functional_async_start(): chat_input = ChatInput(_id="chat_input") chat_output = ChatOutput(input_value="test", _id="chat_output") diff --git a/src/backend/tests/unit/schema/test_schema_message.py b/src/backend/tests/unit/schema/test_schema_message.py index 6ea7da610..68aa38f38 100644 --- a/src/backend/tests/unit/schema/test_schema_message.py +++ b/src/backend/tests/unit/schema/test_schema_message.py @@ -1,9 +1,7 @@ -import pytest from langchain_core.prompts.chat import ChatPromptTemplate from langflow.schema.message import Message -@pytest.mark.asyncio async def test_message_async_prompt_serialization(): template = "Hello, {name}!" message = await Message.from_template_and_variables(template, name="Langflow") diff --git a/src/backend/tests/unit/test_data_components.py b/src/backend/tests/unit/test_data_components.py index 05d9fa974..6dc0db9f0 100644 --- a/src/backend/tests/unit/test_data_components.py +++ b/src/backend/tests/unit/test_data_components.py @@ -15,7 +15,6 @@ def api_request(): return data.APIRequestComponent() -@pytest.mark.asyncio @respx.mock async def test_successful_get_request(api_request): # Mocking a successful GET request @@ -53,7 +52,6 @@ def test_parse_curl(api_request): assert new_build_config["body"]["value"] == {"key": "value"} -@pytest.mark.asyncio @respx.mock async def test_failed_request(api_request): # Mocking a failed GET request @@ -68,7 +66,6 @@ async def test_failed_request(api_request): assert result.data["status_code"] == 404 -@pytest.mark.asyncio @respx.mock async def test_timeout(api_request): # Mocking a timeout @@ -84,7 +81,6 @@ async def test_timeout(api_request): assert result.data["error"] == "Request timed out" -@pytest.mark.asyncio @respx.mock async def test_build_with_multiple_urls(api_request): # This test depends on having a working internet connection and accessible URLs diff --git a/src/backend/tests/unit/test_database.py b/src/backend/tests/unit/test_database.py index 8691012f8..848b46e50 100644 --- a/src/backend/tests/unit/test_database.py +++ b/src/backend/tests/unit/test_database.py @@ -276,7 +276,6 @@ async def test_delete_flows(client: AsyncClient, logged_in_headers): assert response.json().get("deleted") == number_of_flows -@pytest.mark.asyncio @pytest.mark.usefixtures("active_user") async def test_delete_flows_with_transaction_and_build(client: AsyncClient, logged_in_headers): # Create ten flows @@ -335,7 +334,6 @@ async def test_delete_flows_with_transaction_and_build(client: AsyncClient, logg assert response.json() == {"vertex_builds": {}} -@pytest.mark.asyncio @pytest.mark.usefixtures("active_user") async def test_delete_folder_with_flows_with_transaction_and_build(client: AsyncClient, logged_in_headers): # Create a new folder diff --git a/src/backend/tests/unit/test_initial_setup.py b/src/backend/tests/unit/test_initial_setup.py index 5236c1b0b..231b29d17 100644 --- a/src/backend/tests/unit/test_initial_setup.py +++ b/src/backend/tests/unit/test_initial_setup.py @@ -47,7 +47,6 @@ def test_get_project_data(): assert isinstance(project_icon_bg_color, str) or project_icon_bg_color is None -@pytest.mark.asyncio @pytest.mark.usefixtures("client") async def test_create_or_update_starter_projects(): with session_scope() as session: @@ -65,7 +64,6 @@ async def test_create_or_update_starter_projects(): # Some starter projects require integration -# @pytest.mark.asyncio # async def test_starter_projects_can_run_successfully(client): # with session_scope() as session: # # Run the function to create or update projects @@ -128,7 +126,6 @@ def add_edge(source, target, from_output, to_input): } -@pytest.mark.asyncio async def test_refresh_starter_projects(): data_path = str(Path(__file__).parent.parent.parent.absolute() / "base" / "langflow" / "components") components = build_custom_component_list_from_path(data_path) diff --git a/src/backend/tests/unit/test_process.py b/src/backend/tests/unit/test_process.py index d909b63e0..65680cd38 100644 --- a/src/backend/tests/unit/test_process.py +++ b/src/backend/tests/unit/test_process.py @@ -1,4 +1,3 @@ -import pytest from langflow.processing.process import process_tweaks from langflow.services.deps import get_session_service @@ -262,7 +261,6 @@ def test_tweak_not_in_template(): assert result == graph_data -@pytest.mark.asyncio async def test_load_langchain_object_with_cached_session(basic_graph_data): # Provide a non-existent session_id session_service = get_session_service() @@ -276,7 +274,6 @@ async def test_load_langchain_object_with_cached_session(basic_graph_data): # TODO: Update basic graph data -# @pytest.mark.asyncio # async def test_load_langchain_object_with_no_cached_session(client, basic_graph_data): # # Provide a non-existent session_id # session_service = get_session_service() @@ -296,7 +293,6 @@ async def test_load_langchain_object_with_cached_session(basic_graph_data): # assert id(graph1) != id(graph2) -# @pytest.mark.asyncio # async def test_load_langchain_object_without_session_id(client, basic_graph_data): # # Provide a non-existent session_id # session_service = get_session_service()