deepseek根据需求文档生成测试用例

本文将介绍如何从 DOCX 文档中提取标题为“需求内容”的部分,并将其作为 DeepSeek 模型的输入,生成详细且格式化的测试用例。我们将使用 Python 编写相关脚本,并展示最终的测试用例输出格式。

目标

  1. 从 DOCX 文件中读取标题为“需求内容”的部分。
  2. 将提取的内容用作 DeepSeek 模型的输入生成详细的测试用例。
  3. 将测试用例写入 Excel 文件,包含用例标题、步骤和预期结果等信息。

步骤 1:安装所需库

确保安装以下库:

pip install requests python-docx pandas openpyxl

步骤 2:读取 DOCX 文件并提取需求内容

编写一个函数,从 DOCX 文件中提取标题为“需求内容”的部分:

from docx import Document

def read_requirements_section(file_path, section_title="需求内容"):
    doc = Document(file_path)
    content = []
    capture = False

    for para in doc.paragraphs:
        if para.style.name == 'Heading 1' and para.text == section_title:
            capture = True
            continue
        if capture:
            if para.style.name.startswith('Heading'):
                break
            content.append(para.text)

    return '\n'.join(content)

步骤 3:调用 DeepSeek 模型

定义调用 DeepSeek 模型的函数:

import requests

DEESEEK_API_URL = "http://localhost:11434/api/generate"

def call_deepseek(input_text):
    data = {
   "input": input_text}
    
    response = requests.post(DEESEEK_API_URL, json=data)
    
    if response.status_code == 200:
        return response.json()
    else:
        raise Exception(f"Error: {
     response.status_code} - {
     response
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Python测试之道

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值