diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2023-02-12 09:27:25 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2023-02-12 11:52:05 -0500 |
commit | f77be1770a9d93ed69d6b5a26dcbe5dbfe14e380 (patch) | |
tree | 57ee04342aef1966e9a73563306f5dceb415b6a5 /coverage/control.py | |
parent | 6bc043981f6548852844ea6b16d5ef7d37c0417d (diff) | |
download | python-coveragepy-git-f77be1770a9d93ed69d6b5a26dcbe5dbfe14e380.tar.gz |
fix: Path objects are ok for data_file and config_file. #1552
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/coverage/control.py b/coverage/control.py index cdea42ee..e385f0e2 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -47,7 +47,7 @@ from coverage.report import render_report from coverage.results import Analysis from coverage.summary import SummaryReporter from coverage.types import ( - TConfigurable, TConfigSectionIn, TConfigValueIn, TConfigValueOut, + FilePath, TConfigurable, TConfigSectionIn, TConfigValueIn, TConfigValueOut, TFileDisposition, TLineNo, TMorf, ) from coverage.xmlreport import XmlReporter @@ -113,13 +113,13 @@ class Coverage(TConfigurable): def __init__( # pylint: disable=too-many-arguments self, - data_file: Optional[Union[str, DefaultValue]] = DEFAULT_DATAFILE, + data_file: Optional[Union[FilePath, DefaultValue]] = DEFAULT_DATAFILE, data_suffix: Optional[Union[str, bool]] = None, cover_pylib: Optional[bool] = None, auto_data: bool = False, timid: Optional[bool] = None, branch: Optional[bool] = None, - config_file: Union[str, bool] = True, + config_file: Union[FilePath, bool] = True, source: Optional[Iterable[str]] = None, source_pkgs: Optional[Iterable[str]] = None, omit: Optional[Union[str, Iterable[str]]] = None, @@ -227,6 +227,8 @@ class Coverage(TConfigurable): self._no_disk = data_file is None if isinstance(data_file, DefaultValue): data_file = None + if data_file is not None: + data_file = os.fspath(data_file) # This is injectable by tests. self._debug_file: Optional[IO[str]] = None @@ -267,6 +269,8 @@ class Coverage(TConfigurable): self._should_write_debug = True # Build our configuration from a number of sources. + if not isinstance(config_file, bool): + config_file = os.fspath(config_file) self.config = read_coverage_config( config_file=config_file, warn=self._warn, |