gpt4 book ai didi

python - 如何让 PyTest 在 Github 中找到我的测试?

转载 作者:行者123 更新时间:2023-12-04 09:03:48 25 4
gpt4 key购买 nike

我有一个项目布局如下:

ProjectRoot
|
\---------CoreImplelemntation
| |
| \--CoreSourceFile1.py
| \--Test_CoreSourceFile1.py
|
\---------WebUIThatReferencesCoreImplentation
|
\--WebSourceFile1.py
\--Test_WebSourceFile1.py

我可以在本地运行(从项目的根文件夹)pipenv run pytest,我的所有测试都在这些子目录中被发现并执行。

然而,当我尝试在 github 的工作流程中执行此操作时,以下所有情况都导致没有运行测试:

    - name: Test with pytest
run: |
pytest
    - name: Test with pytest
run: |
pipenv run pytest
    - name: Test with pytest
run: |
pipenv run pytest .

每次输出看起来像这样:

Run pipenv run pytest .
Creating a virtualenv for this project...
Pipfile: /home/runner/work/ed-scout/ed-scout/Pipfile
Using /opt/hostedtoolcache/Python/3.7.8/x64/bin/python3.7m (3.7.8) to create virtualenv...
created virtual environment CPython3.7.8.final.0-64 in 452ms
creator CPython3Posix(dest=/home/runner/.local/share/virtualenvs/ed-scout-bRIm7jsM, clear=False, global=False)
seeder FromAppData(download=False, pip=bundle, wheel=bundle, setuptools=bundle, via=copy, app_data_dir=/home/runner/.local/share/virtualenv)
added seed packages: pip==20.2.2, setuptools==49.6.0, wheel==0.35.1
activators PythonActivator,FishActivator,XonshActivator,CShellActivator,PowerShellActivator,BashActivator


Successfully created virtual environment!
Virtualenv location: /home/runner/.local/share/virtualenvs/ed-scout-bRIm7jsM
============================= test session starts ==============================
platform linux -- Python 3.7.8, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: /home/runner/work/ed-scout/ed-scout
collected 0 items

============================ no tests ran in 0.03s =============================
##[error]Process completed with exit code 5.

工作流文件如下:https://github.com/joncage/ed-scout/pull/18/files

我是否缺少一些魔法来让它运行或询问这里出了什么问题?

最佳答案

原来我是在 Windows 机器上本地运行我的测试,而 github 测试是在 linux 下运行的。 PyTest 寻找 test... 文件,而我有 Test... 文件,所以这是一个区分大小写的问题;重命名测试文件允许 PyTest 找到它们。

关于python - 如何让 PyTest 在 Github 中找到我的测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63501397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com