Skip to content

Commit

Permalink
self.abs_cov_config_file from coverage.py's config
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Mar 30, 2019
1 parent 4082617 commit 7c0d4c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
17 changes: 13 additions & 4 deletions src/pytest_cov/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ def set_env(self):
os.environ['COV_CORE_SOURCE'] = os.pathsep
else:
os.environ['COV_CORE_SOURCE'] = os.pathsep.join(self.cov_source)
config_file = os.path.abspath(self.cov_config)
if os.path.exists(config_file):
os.environ['COV_CORE_CONFIG'] = config_file
if self.abs_cov_config_file:
os.environ['COV_CORE_CONFIG'] = self.abs_cov_config_file
else:
os.environ['COV_CORE_CONFIG'] = os.pathsep
os.environ['COV_CORE_DATAFILE'] = os.path.abspath(self.cov.config.data_file)
Expand Down Expand Up @@ -151,10 +150,20 @@ def start(self):
self.cov = coverage.Coverage(source=self.cov_source,
branch=self.cov_branch,
config_file=self.cov_config)

# Get absolute location of used config file.
parsed_config_file = self.cov.config.config_file
if parsed_config_file:
parsed_config_file = os.path.abspath(parsed_config_file)
assert os.path.exists(parsed_config_file)
self.abs_cov_config_file = parsed_config_file
else:
self.abs_cov_config_file = False

self.combining_cov = coverage.Coverage(source=self.cov_source,
branch=self.cov_branch,
data_file=os.path.abspath(self.cov.config.data_file),
config_file=self.cov_config)
config_file=parsed_config_file)

# Erase or load any previous coverage data and start coverage.
if self.cov_append:
Expand Down
5 changes: 3 additions & 2 deletions src/pytest_cov/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ def pytest_addoption(parser):
'annotate, html and xml may be followed by ":DEST" '
'where DEST specifies the output location. '
'Use --cov-report= to not generate any output.')
group.addoption('--cov-config', action='store', default='.coveragerc',
group.addoption('--cov-config', action='store', default=True,
metavar='path',
help='Config file for coverage. Default: .coveragerc')
help=('Config file for coverage. '
'By default ".coveragerc", "setup.cfg" and "tox.ini" are tried.'))
group.addoption('--no-cov-on-fail', action='store_true', default=False,
help='Do not report coverage if test run fails. '
'Default: False')
Expand Down

0 comments on commit 7c0d4c9

Please sign in to comment.