Giter Site home page Giter Site logo

Python raw coverage report shows 0% about pants HOT 4 OPEN

idan-at avatar idan-at commented on May 24, 2024
Python raw coverage report shows 0%

from pants.

Comments (4)

idan-at avatar idan-at commented on May 24, 2024 1

I've tried updating the filename of the config from the example above to end with .toml, didn't help

from pants.

jensenja avatar jensenja commented on May 24, 2024

Hi,

You are missing relative_files = true under your [run] section in .coveragerc. Per the documentation, this is required for Pants to work. Adding this produces the expected output in your HTML report generated by check.py in your repository:

Screenshot 2023-12-24 at 3 55 08 PM

from pants.

idan-at avatar idan-at commented on May 24, 2024

Thanks John, I totally missed the docs for that. Closing this issue.

from pants.

huonw avatar huonw commented on May 24, 2024

Hm, I think there's something deeper going on here: Pants attempts to set that property itself, but that is seemingly not working:

def _update_config(fc: FileContent) -> FileContent:
if PurePath(fc.path).suffix == ".toml":
all_config = _parse_toml_config(fc)
tool = all_config.setdefault("tool", {})
coverage = tool.setdefault("coverage", {})
run = coverage.setdefault("run", {})
run["relative_files"] = True
if "pytest.pex/*" not in run.get("omit", []):
run["omit"] = [*run.get("omit", []), "pytest.pex/*"]
return FileContent(fc.path, toml.dumps(all_config).encode())
cp = _parse_ini_config(fc)
run_section = "coverage:run" if fc.path in ("tox.ini", "setup.cfg") else "run"
if not cp.has_section(run_section):
cp.add_section(run_section)
cp.set(run_section, "relative_files", "True")
omit_elements = cp[run_section].get("omit", "").split("\n") or ["\n"]
if "pytest.pex/*" not in omit_elements:
omit_elements.append("pytest.pex/*")
cp.set(run_section, "omit", "\n".join(omit_elements))
stream = StringIO()
cp.write(stream)
return FileContent(fc.path, stream.getvalue().encode())

As such, reopening.

from pants.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.