summaryrefslogtreecommitdiff
path: root/coverage/control.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-08-05 05:19:54 -0700
committerGitHub <noreply@github.com>2021-08-05 05:19:54 -0700
commit602e2106edfe437adf56bced4da2e09eb32ca765 (patch)
tree17ae7ebe1f7b8f61032aa69fce11a8111463fb4e /coverage/control.py
parent57a691f15dc8296f91ec1e321d3ed53e165a1f10 (diff)
downloadpython-coveragepy-git-602e2106edfe437adf56bced4da2e09eb32ca765.tar.gz
feat: unrecognized options are now a warning rather than error. #1035 (#1206)
Because they are warnings issued while parsing the configuration file, it's not possible to suppress them with the coverage configuration.
Diffstat (limited to 'coverage/control.py')
-rw-r--r--coverage/control.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/coverage/control.py b/coverage/control.py
index e1eb9add..c45b1245 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -192,15 +192,7 @@ class Coverage:
if data_file is _DEFAULT_DATAFILE:
data_file = None
- # Build our configuration from a number of sources.
- self.config = read_coverage_config(
- config_file=config_file,
- data_file=data_file, cover_pylib=cover_pylib, timid=timid,
- branch=branch, parallel=bool_or_none(data_suffix),
- source=source, source_pkgs=source_pkgs, run_omit=omit, run_include=include, debug=debug,
- report_omit=omit, report_include=include,
- concurrency=concurrency, context=context,
- )
+ self.config = None
# This is injectable by tests.
self._debug_file = None
@@ -235,6 +227,16 @@ class Coverage:
# Should we write the debug output?
self._should_write_debug = True
+ # Build our configuration from a number of sources.
+ self.config = read_coverage_config(
+ config_file=config_file, warn=self._warn,
+ data_file=data_file, cover_pylib=cover_pylib, timid=timid,
+ branch=branch, parallel=bool_or_none(data_suffix),
+ source=source, source_pkgs=source_pkgs, run_omit=omit, run_include=include, debug=debug,
+ report_omit=omit, report_include=include,
+ concurrency=concurrency, context=context,
+ )
+
# If we have sub-process measurement happening automatically, then we
# want any explicit creation of a Coverage object to mean, this process
# is already coverage-aware, so don't auto-measure it. By now, the
@@ -352,16 +354,18 @@ class Coverage:
"""
if self._no_warn_slugs is None:
- self._no_warn_slugs = list(self.config.disable_warnings)
+ if self.config is not None:
+ self._no_warn_slugs = list(self.config.disable_warnings)
- if slug in self._no_warn_slugs:
- # Don't issue the warning
- return
+ if self._no_warn_slugs is not None:
+ if slug in self._no_warn_slugs:
+ # Don't issue the warning
+ return
self._warnings.append(msg)
if slug:
msg = f"{msg} ({slug})"
- if self._debug.should('pid'):
+ if self._debug is not None and self._debug.should('pid'):
msg = f"[{os.getpid()}] {msg}"
warnings.warn(msg, category=CoverageWarning, stacklevel=2)