codecov无法使用pytest收集数据“覆盖率.py警告:未收集数据。“

2024-09-21 00:49:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在我的公共travis repo上设置codecov,但到目前为止还无法成功生成报告并将其上载到编解码器.io. 我似乎在终端收到了一个错误的报告,说我的代码有0%被覆盖了,并发出警告。在

据我所知,我的。特拉维斯·伊梅尔和shell脚本完全符合pytest cov和codecov文档中指定的约定。在

包含完整日志的travis终端在这里:https://www.travis-ci.com/jmaggio14/imagepypelines/jobs/163802897#L681

我的回购可以在这里找到:https://github.com/jmaggio14/imagepypelines/tree/89a6bbc2fadc94a51570d80be356941df1a87a87

我的(简称)。特拉维斯·伊梅尔文件如下:

 sudo: false

  language: python

  python:
      - 2.7
      - 3.4
      - 3.5
      - 3.6

  install:
    # I removed some other lines for readability here
    - pip install codecov pytest-cov hypothesis

  script:
    # running tests and code coverage report
    - py.test --cov=imagepypelines tests/


  after_success:
    - codecov

最后我收到了以下警告和一条消息:我的测试覆盖了0%的代码

^{pr2}$

Tags: install代码httpscomtraviscodecov终端警告
1条回答
网友
1楼 · 发布于 2024-09-21 00:49:55

我在本地运行测试时重现了这个问题,发现coverage需要tests文件夹包含一个__init__.py才能收集任何数据。在

我将__init__.py添加到tests文件夹中,然后coverage按预期收集了数据。在

{a1}

相关问题 更多 >

    热门问题