测试覆盖报告未通过子进程模块正确生成

发布于 2025-02-09 14:53:47 字数 918 浏览 1 评论 0原文

我正在使用Pycov生成我开发的Python工具的覆盖范围报告。

工作流♻: - 测试脚本 - >辅助文件的调用函数(使用 subprocess tool.py.py ) - > stdout 退回并将其返回到测试脚本


获取 > 即使是在测试阶段击中的代码块,它们也被显示为在Pycov生成的覆盖范围报告中没有涵盖。


此脚本运行所有测试脚本。

for i in file_list:
    if i.startswith("test_"):
        test_files.append(i)
for file in test_files:
    result_file_name = file.split(".")[0] + ".xml"
    pytest.main([file, "-o", "junit_logging=system-out","--disable-pytest-warnings",
              "--junitxml=" + result_folder + result_file_name, "--tb=line",
              "--cov", "--cov-config=.coveragerc", "--cov-report=html", "--cov-report=", "--cov-append"])

在.coveragerc文件中,

[run]
branch = True
dynamic_context = test_function
include = Tool.py

有人知道解决方案吗?请让我知道,谢谢!

I'm using pycov to generate the coverage report for a python tool that I've developed.

Workflow ♻:- Test Script -> Calls function from Helper File (Uses Subprocess to interact with Tool.py) -> Gets the stdout back and returns it to the test script.

Coverage report needs to be generated for Tool.py


Even the the codeblocks are hit during the testing phase, they are being shown as not being covered in the coverage report generated in pycov.


This script runs all the test scripts.

for i in file_list:
    if i.startswith("test_"):
        test_files.append(i)
for file in test_files:
    result_file_name = file.split(".")[0] + ".xml"
    pytest.main([file, "-o", "junit_logging=system-out","--disable-pytest-warnings",
              "--junitxml=" + result_folder + result_file_name, "--tb=line",
              "--cov", "--cov-config=.coveragerc", "--cov-report=html", "--cov-report=", "--cov-append"])

In the .coveragerc file

[run]
branch = True
dynamic_context = test_function
include = Tool.py

Does anybody know a solution for this? Please do let me know, thanks!????

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文