Skip to content

Allow pyproject.toml to override a global coveragerc #1723

Open
@crazystick

Description

@crazystick

Is your feature request related to a problem? Please describe.
I maintain a docker image which is used for testing multiple different projects, and I'd like to provide a set of global defaults for coverage but be able to override them per project in pyproject.toml

Describe the solution you'd like
I would like config to be loaded first from a global default file, e.g. /etc/coveragerc which would replace any defaults from CoverageConfig. After this the existing logic which reads the various configuration files (and exits as soon as it finds a valid one) will still work fine. I also believe this implementation will not break existing configurations.

Describe alternatives you've considered
I tried passing config directly on the command line and via a specified config file, but because read_coverage_config breaks as soon as it finds the first valid configuration file, it didn't work.

It could be possible to just remove the early exit in read_coverage_config but that would potentially break people's existing configuration.

Additional context
The main thing I'd like to specify in the global defaults is fail_under - I would like to have a target that is organisation wide, and anyone configuring a different value via a pyproject.toml would be a red flag. Sometimes it's just not practical to hit the target though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions