🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
feat: +unit test
莘权 马cfedba061afc
diff --git a/.gitignore b/.gitignoreindex 039ba1956..67c2fa316 100644--- a/.gitignore+++ b/.gitignore@@ -166,3 +166,4 @@ outputtmp.png.dependencies.jsontests/metagpt/utils/file_repo_git+*.tmpdiff --git a/tests/metagpt/tools/test_ut_writer.py b/tests/metagpt/tools/test_ut_writer.pyindex 2ae94885f..e31afa702 100644--- a/tests/metagpt/tools/test_ut_writer.py+++ b/tests/metagpt/tools/test_ut_writer.py@@ -3,8 +3,11 @@"""@Time : 2023/4/30 21:44@Author : alexanderwu-@File : test_ut_generator.py+@File : test_ut_writer.py"""+from pathlib import Path++import pytestfrom metagpt.const import API_QUESTIONS_PATH, SWAGGER_PATH, UT_PY_PATHfrom metagpt.tools.ut_writer import YFT_PROMPT_PREFIX, UTGenerator@@ -12,7 +15,10 @@ from metagpt.tools.ut_writer import YFT_PROMPT_PREFIX, UTGeneratorclass TestUTWriter:def test_api_to_ut_sample(self):+ # Prerequisitesswagger_file = SWAGGER_PATH / "yft_swaggerApi.json"+ assert swagger_file.exists()+tags = ["测试"] # "智能合同导入", "律师审查", "ai合同审查", "草拟合同&律师在线审查", "合同审批", "履约管理", "签约公司"]# 这里在文件中手动加入了两个测试标签的API@@ -25,3 +31,12 @@ class TestUTWriter:ret = utg.generate_ut(include_tags=tags)# 后续加入对文件生成内容与数量的检验assert ret++ pathname = Path(__file__).with_suffix(".tmp")+ utg.ask_gpt_and_save(question="question", tag="tag", fname=str(pathname))+ assert pathname.exists()+ pathname.unlink(missing_ok=True)+++if __name__ == "__main__":+ pytest.main([__file__, "-s"])