We use SonarCloud - Github with Github Actions.
Our repository : Python , pytest
For getting test coverage properly I used the build.yml as suggested here. I only edited the tox.ini file and .properties file. But I have problem for tox file:
[tox]
envlist = py39
skipsdist = True
[testenv]
deps =
pytest
coverage
commands = pytest --cov={my project name} --cov-report=xml --cov-config=tox.ini --cov-branch
[coverage:run]
However, when it is executed on Github Actions, I get the error below:
py: install_deps> python -I -m pip install coverage pytest
py: freeze> python -m pip freeze --all
py:attrs==22.2.0,coverage==7.0.4,exceptiongroup==1.1.0,iniconfig==2.0.0,packaging==23.0,pip==22.3.1,pluggy==1.0.0,pytest==7.2.0,setuptools==65.6.3,tomli==2.0.1,wheel==0.38.4
py: commands[0]> pytest --cov={my project name} --cov-report=xml --cov-config=tox.ini --cov-branch
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] […]
pytest: error: unrecognized arguments: --cov={my project name} --cov-report=xml --cov-config=tox.ini --cov-branch
inifile: None
rootdir: /home/runner/work/{my project name}/{my project name}
py: exit 4 (0.19 seconds) /home/runner/work/{my project name}/{my project name}> pytest --cov={my project name} --cov-report=xml --cov-config=tox.ini --cov-branch pid=1977
py: FAIL code 4 (3.40=setup[3.21]+cmd[0.19] seconds)
evaluation failed
(3.46 seconds)
Error: Process completed with exit code 4.
- How can I solve this issue?
- What is the correct way to write project name?
{organisation name}-{project name}
? - What should be written for pytest attributes?:
- –cov=
- –cov-report=
- –cov-config=
- –cov-branch=