AlexMedeiros
AlexMedeiros

Reputation: 25

Coverage appears to load coveragerc file, but all configuration remains default

I may be missing something obvious here, but I don't seem to be able to get coverage to load configuration data from a .coveragerc file when being used as an imported module, although it does seem to be checking that the configuration file is present. First, here is the full contents of my .coveragerc:

[Run]
branch = True

[Report]
show_missing = True
skip_covered = True

More specifically, this snippet of code confirms that it does see the file, as it prints out ['.coveragerc'], as expected.

cov = coverage.Coverage(config_file='.coveragerc')
print(cov.config.config_files)

When the config file name is changed to a file that does not exist (such as .notcoveragerc), I get this exception that seems to confirm that the code above is successfully loading a file, or at least verifying its existence.

coverage.misc.CoverageException: Couldn't read '.notcoveragerc' as a config file

However, if I check any of the other values that I expect to be changed from their defaults based on the contents of my .coveragerc, I can see that they have not been changed.

cov = coverage.Coverage(config_file='.coveragerc')
print(cov.config.config_files)
print(cov.config.branch)
print(cov.config.show_missing)
print(cov.config.skip_covered)

The above code outputs the following:

['.testcoveragerc']
False
False
False

Am I missing something obvious in the documentation or is this something I should file a bug report for?

Upvotes: 2

Views: 4631

Answers (2)

disaza
disaza

Reputation: 1

I encountered the exact same issue.

I was able to resolve it by moving .coveragerc into the same folder as manage.py.

Upvotes: 0

Ned Batchelder
Ned Batchelder

Reputation: 375574

Your section names should be lowercase: [run], not [Run].

Upvotes: 4

Related Questions