pytest collects and passes tests locally, but 'collected 0 items' in GitHub Actions workflow (exit code 5)

huangapple go评论91阅读模式
英文:

pytest collects and passes tests locally, but 'collected 0 items' in GitHub Actions workflow (exit code 5)

问题

我对GitHub Actions工作流程还不太了解,遇到了与pytest相关的问题。在本地,我的测试成功收集并通过了,没有任何问题。但是,在GitHub Actions工作流中运行相同的测试时,pytest无法识别任何测试,并显示错误消息“collected 0 items”,退出代码为5。

我已经按照pytest的命名约定命名了测试文件、测试类和测试函数:

文件名:test_example.py

类名:TestExample

函数名:test_example

为了运行测试,我使用以下命令:

pytest --doctest-modules --durations=10 --pyargs <package name>

为了提供更多上下文信息,我创建了一个简单的存储库,您可以在其中找到代码:github

如果需要,我很乐意提供更多信息。

英文:

I'm new to GitHub Actions workflows and encountering an issue with pytest. Locally, my tests are successfully collected and pass without any problems. However, when running the same tests in a GitHub Actions workflow, pytest fails to recognize any tests and displays the error "collected 0 items" with exit code 5.

I have followed the pytest naming conventions by naming the test file, the test class, and the test function appropriately:

File name: test_example.py

Class name: TestExample

Function name: test_example

For running the test, I use the following command:

pytest --doctest-modules --durations=10 --pyargs <package name>

To provide more context, I've created a simple repository where you can find the code: github

Any insights or suggestions on how to resolve this issue would be greatly appreciated. I'm happy to provide more information if needed.

答案1

得分: 1

问题已通过从pytest命令中删除对pyargs的使用来解决。

英文:

Ok, so the issue was resolved by removing the usage of pyargs from the pytest command..

huangapple
  • 本文由 发表于 2023年6月9日 02:30:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76434747.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定