mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
fix: Refactor try-except loop to resolve PERF203 lint issue
Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import pytest
|
||||
|
||||
from crewai.agents import parser
|
||||
from crewai.agents.crew_agent_executor import (
|
||||
AgentAction,
|
||||
AgentFinish,
|
||||
OutputParserException,
|
||||
)
|
||||
from crewai.agents import parser
|
||||
|
||||
|
||||
def test_valid_action_parsing_special_characters():
|
||||
@@ -345,12 +345,16 @@ def test_integration_valid_and_invalid():
|
||||
"""
|
||||
parts = text.strip().split("\n\n")
|
||||
results = []
|
||||
for part in parts:
|
||||
|
||||
def parse_part(part_text):
|
||||
try:
|
||||
result = parser.parse(part.strip())
|
||||
results.append(result)
|
||||
return parser.parse(part_text.strip())
|
||||
except OutputParserException as e:
|
||||
results.append(e)
|
||||
return e
|
||||
|
||||
for part in parts:
|
||||
result = parse_part(part)
|
||||
results.append(result)
|
||||
|
||||
assert isinstance(results[0], AgentAction)
|
||||
assert isinstance(results[1], AgentFinish)
|
||||
@@ -452,4 +456,3 @@ def test_format_registry():
|
||||
|
||||
def test_backward_compatibility():
|
||||
"""Test that all existing ReAct format tests still pass."""
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user