Modify to make LLM a fixture in test cases

This commit is contained in:
mannaandpoem 2024-01-03 14:41:49 +08:00
parent b19995f083
commit 0ed2c56035
4 changed files with 14 additions and 9 deletions

View file

@ -92,7 +92,9 @@ CONTEXT = """
"""
llm = OpenAIGPTAPI()
@pytest.fixture()
def llm():
return OpenAIGPTAPI()
@pytest.mark.asyncio

View file

@ -131,11 +131,14 @@ CONTEXT = """
}
"""
llm = OpenAIGPTAPI()
@pytest.fixture()
def llm():
return OpenAIGPTAPI()
@pytest.mark.asyncio
async def test_project_management_an():
async def test_project_management_an(llm):
node = await REFINED_PM_NODES.fill(CONTEXT, llm)
assert node.instruct_content
assert "Refined Logic Analysis" in node.instruct_content.json(ensure_ascii=False)

View file

@ -7,7 +7,7 @@
"""
import pytest
from metagpt.actions import WriteCode
from metagpt.actions.write_code import WriteCode
from metagpt.actions.write_code_guideline_an import (
CODE_GUIDELINE_CONTEXT,
CODE_GUIDELINE_SCRIPT_EXAMPLE,
@ -15,7 +15,6 @@ from metagpt.actions.write_code_guideline_an import (
REFINED_CODE_TEMPLATE,
WriteCodeGuideline,
)
from metagpt.provider import OpenAIGPTAPI
REQUIREMENT_EXAMPLE = """Add subtraction, multiplication and division operations to the calculator.
The current calculator can only perform basic addition operations, and it is necessary to introduce subtraction, multiplication, division operation into the calculator
@ -80,8 +79,6 @@ INCREMENTAL_CHANGE_EXAMPLE = """
}
"""
llm = OpenAIGPTAPI()
@pytest.mark.asyncio
async def test_write_code_guideline_an():

View file

@ -75,11 +75,14 @@ Please change the game's score target from 2048 to 4096, and change the interfac
-
"""
llm = OpenAIGPTAPI()
@pytest.fixture()
def llm():
return OpenAIGPTAPI()
@pytest.mark.asyncio
async def test_write_prd_an():
async def test_write_prd_an(llm):
node = await REFINE_PRD_NODE.fill(CONTEXT, llm)
assert node.instruct_content
assert "Refined Requirement Pool" in node.instruct_content.json(ensure_ascii=False)