exasol / python-toolbox

Infrastructure & Automation Tooling for Python Projects
https://exasol.github.io/python-toolbox/
MIT License
2 stars 0 forks source link

🐞 Coverage report on new empty project fails hiding stderr of subproccess #222

Open ckunki opened 1 month ago

ckunki commented 1 month ago

File exasol/toolbox/metrics.py in method total_coverage() calls subprocess.run():

        run(
            ["coverage", "json", f"--data-file={file}", "-o", f"{report}"],
            capture_output=True,
            check=True,
        )

A sample CI build displays the following error message.

subprocess.CalledProcessError: Command '['coverage', 'json', 
'--data-file=.coverage', 
'-o', '/tmp/tmpd9c4d11b/coverage.json']' 
returned non-zero exit status 2.
nox > Session report failed.

The current ticket proposes to

Additionally

I was able to make coverage report terminate successfully by

File __init__.py:

def sample_function():
    return True

file test/unit/unit_smoke_test.py:

import {{ cookiecutter.import_package }}

def test_unit_smoke_test():
    assert {{cookiecutter.package_name}}.sample_function() 
Nicoretti commented 1 month ago

Importing the pre-existing version constant(s) would likely yield a more sensible test.

For example, a unit test that verifies the version in version.py is in sync with the version in pyproject.toml could simultaneously address two issues:

  1. The explicit version check workflow step could be eliminated.
  2. Some code from the module in question would be tested.