Skip to content

Does not consult files at project root #692

Open
@madduck

Description

@madduck

Summary

If pytest runs in e.g. ./tests/, it reads ../pyproject.toml for configuration options, and that squares with my expectation. pytest-cov does seem to look only for ./pyproject.toml (and also writes ./.coverage instead of keeping that file at the project root), and that causes it to run with different settings depending on where pytest is invoked.

Case in point, I have this in my config:

[tool.coverage.report]
exclude_also = [
  'def __repr__',
]

If I run pytest from the project root directory, I get 100% coverage. If I run it from the tests/ subdirectory, all __repr__ functions, which I don't test, get reports as uncovered.

Reproducer

Versions

pytest                       8.3.5
pytest-cov                   6.1.1
coverage                     7.8.0

Python 3.13.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions