pytest-ml-测试器 pytest-ml-tester

pytest-ml-测试器是一个专门用于机器学习项目的自动化测试工具。它基于pytest框架,提供了一系列针对机器学习工作流的专用夹具和测试工具,包括数据验证、模型加载、预测测试、性能回归和集成测试。该工具旨在确保机器学习系统的可靠性、可重复性和代码质量,支持覆盖率报告和参数化测试生成,是机器学习开发和部署流程中不可或缺的测试环节。关键词:机器学习测试,pytest夹具,数据验证,模型评估,集成测试,自动化测试,代码覆盖率,MLOps。

测试 0 次安装 0 次浏览 更新于 2/23/2026

名称: pytest-ml-测试器 描述: 使用pytest进行机器学习特定测试的技能,包含数据、模型和预测的专用夹具。 允许使用的工具:

  • 读取
  • 写入
  • Bash
  • Glob
  • Grep

pytest-ml-测试器

概述

使用pytest进行机器学习特定测试的技能,包含用于数据验证、模型加载、预测测试和机器学习管道验证的专用夹具。

功能

  • 数据验证夹具
  • 模型加载夹具
  • 预测测试工具
  • 性能回归测试
  • 集成测试助手
  • 机器学习代码覆盖率报告
  • 使用Hypothesis进行基于属性的测试
  • 参数化测试生成

目标流程

  • 机器学习系统集成测试
  • 模型评估与验证框架
  • 数据收集与验证管道

工具与库

  • pytest
  • pytest-cov
  • hypothesis
  • great-expectations (可选)

输入模式

{
  "type": "object",
  "required": ["action"],
  "properties": {
    "action": {
      "type": "string",
      "enum": ["run", "generate", "coverage", "fixtures"],
      "description": "要执行的测试操作"
    },
    "testConfig": {
      "type": "object",
      "properties": {
        "testPath": { "type": "string" },
        "markers": { "type": "array", "items": { "type": "string" } },
        "verbose": { "type": "boolean" },
        "failFast": { "type": "boolean" },
        "parallel": { "type": "integer" }
      }
    },
    "coverageConfig": {
      "type": "object",
      "properties": {
        "sourcePath": { "type": "string" },
        "minCoverage": { "type": "number" },
        "reportFormat": { "type": "string", "enum": ["html", "xml", "term"] }
      }
    },
    "generateConfig": {
      "type": "object",
      "properties": {
        "testType": {
          "type": "string",
          "enum": ["data_validation", "model_inference", "performance", "integration"]
        },
        "targetPath": { "type": "string" },
        "modelPath": { "type": "string" },
        "dataPath": { "type": "string" }
      }
    },
    "fixtureConfig": {
      "type": "object",
      "properties": {
        "dataFixtures": { "type": "array" },
        "modelFixtures": { "type": "array" },
        "scope": { "type": "string", "enum": ["function", "class", "module", "session"] }
      }
    }
  }
}

输出模式

{
  "type": "object",
  "required": ["status", "results"],
  "properties": {
    "status": {
      "type": "string",
      "enum": ["passed", "failed", "error"]
    },
    "results": {
      "type": "object",
      "properties": {
        "totalTests": { "type": "integer" },
        "passed": { "type": "integer" },
        "failed": { "type": "integer" },
        "skipped": { "type": "integer" },
        "duration": { "type": "number" }
      }
    },
    "failures": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "testName": { "type": "string" },
          "error": { "type": "string" },
          "traceback": { "type": "string" }
        }
      }
    },
    "coverage": {
      "type": "object",
      "properties": {
        "percentage": { "type": "number" },
        "reportPath": { "type": "string" },
        "uncoveredLines": { "type": "object" }
      }
    },
    "generatedTests": {
      "type": "array",
      "items": { "type": "string" }
    }
  }
}

使用示例

{
  kind: 'skill',
  title: '运行机器学习集成测试',
  skill: {
    name: 'pytest-ml-测试器',
    context: {
      action: 'run',
      testConfig: {
        testPath: 'tests/integration/',
        markers: ['integration', 'model'],
        verbose: true,
        parallel: 4
      },
      coverageConfig: {
        sourcePath: 'src/',
        minCoverage: 80,
        reportFormat: 'html'
      }
    }
  }
}