如何让 Pytest 识别我的单元测试文件

问题描述 投票:0回答:1

我目前正在尝试管理我正在学习的大学课程的 GitHub 存储库,并尝试让 CI/CD 要求通过。我已经设法通过了大部分检查,但我不知道如何让它通过 pytest 测试。当到达这个阶段时,会给出以下输出:

    Run pytest --verbose .
============================= test session starts ==============================
platform linux -- Python 3.10.13, pytest-8.0.0, pluggy-1.4.0 -- /opt/hostedtoolcache/Python/3.10.13/x64/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/home/runner/work/OOP-ajsaylor/OOP-ajsaylor/.hypothesis/examples'))
rootdir: /home/runner/work/OOP-ajsaylor/OOP-ajsaylor
plugins: hypothesis-6.98.4
collecting ... collected 0 items

============================ no tests ran in 1.01s =============================
Error: Process completed with exit code 5.

我确实有一个我要测试的程序的单元测试文件,所以我的假设是它找不到测试文件。

因此,我想知道是否有人知道我需要做什么才能让 pytest 找到我的单元测试文件。任何意见将不胜感激。

python github pytest github-actions cicd
1个回答
0
投票

pytest 运行当前目录及其子目录中所有形式为 test_*.py 或 *_test.py 的文件。

更一般地说,它遵循标准测试发现规则

© www.soinside.com 2019 - 2024. All rights reserved.