conftest.py 891 B

1234567891011121314151617181920212223242526272829303132
  1. """
  2. RAG 管线测试 — pytest fixtures
  3. """
  4. import pytest
  5. @pytest.fixture(scope="session")
  6. def pipeline_runner():
  7. """RAG 管线执行器(session 级,避免重复初始化)"""
  8. from utils_test.RAG_Pipeline_Test.rag_pipeline_runner import RAGPipelineRunner
  9. return RAGPipelineRunner()
  10. @pytest.fixture(scope="session")
  11. def evaluator():
  12. """RAG 评估器(session 级)"""
  13. from utils_test.RAG_Pipeline_Test.rag_evaluator import RAGEvaluator
  14. return RAGEvaluator()
  15. @pytest.fixture(scope="session")
  16. def test_samples():
  17. """测试样本列表"""
  18. from utils_test.RAG_Pipeline_Test.test_data import TEST_SAMPLES
  19. return TEST_SAMPLES
  20. @pytest.fixture(scope="session")
  21. def batch_results(pipeline_runner, test_samples):
  22. """批量执行所有测试样本(session 级,所有测试共享结果)"""
  23. return pipeline_runner.run_batch(test_samples)