diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-07-28 19:48:10 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-07-28 19:48:10 -0400 |
commit | 7fe106b9fef26478ba10a6f206baf70eee201d4a (patch) | |
tree | a6e35aafeeea8887899433f5067f00569950ff44 | |
parent | c5c1ba084b0b548ff8869cbc086e81608c329eb6 (diff) | |
download | python-coveragepy-git-7fe106b9fef26478ba10a6f206baf70eee201d4a.tar.gz |
fix: correct previous refactorings
File names should not be rendered with !r, since on Windows that will
produce double backslashes, which only confuses people.
-rw-r--r-- | coverage/data.py | 2 | ||||
-rw-r--r-- | coverage/execfile.py | 8 | ||||
-rw-r--r-- | coverage/inorout.py | 2 | ||||
-rw-r--r-- | coverage/parser.py | 4 | ||||
-rw-r--r-- | coverage/sqldata.py | 2 |
5 files changed, 9 insertions, 9 deletions
diff --git a/coverage/data.py b/coverage/data.py index 7ba51dc8..752822b7 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -91,7 +91,7 @@ def combine_parallel_data(data, aliases=None, data_paths=None, strict=False, kee pattern = os.path.join(os.path.abspath(p), localdot) files_to_combine.extend(glob.glob(pattern)) else: - raise CoverageException(f"Couldn't combine from non-existent path {p!r}") + raise CoverageException(f"Couldn't combine from non-existent path '{p}'") if strict and not files_to_combine: raise CoverageException("No data to combine") diff --git a/coverage/execfile.py b/coverage/execfile.py index 80277815..f46955bc 100644 --- a/coverage/execfile.py +++ b/coverage/execfile.py @@ -192,8 +192,8 @@ class PyRunner: except CoverageException: raise except Exception as exc: - msg = "Couldn't run '{filename}' as Python code: {exc.__class__.__name__}: {exc}" - raise CoverageException(msg.format(filename=self.arg0, exc=exc)) from exc + msg = f"Couldn't run '{self.arg0}' as Python code: {exc.__class__.__name__}: {exc}" + raise CoverageException(msg) from exc # Execute the code object. # Return to the original directory in case the test code exits in @@ -278,7 +278,7 @@ def make_code_from_py(filename): try: source = get_python_source(filename) except (OSError, NoSource) as exc: - raise NoSource(f"No file to run: {filename!r}") from exc + raise NoSource(f"No file to run: '{filename}'") from exc code = compile_unicode(source, filename, "exec") return code @@ -289,7 +289,7 @@ def make_code_from_pyc(filename): try: fpyc = open(filename, "rb") except OSError as exc: - raise NoCode(f"No file to run: {filename!r}") from exc + raise NoCode(f"No file to run: '{filename}'") from exc with fpyc: # First four bytes are a version-specific magic number. It has to diff --git a/coverage/inorout.py b/coverage/inorout.py index a161fa61..75b0a9cc 100644 --- a/coverage/inorout.py +++ b/coverage/inorout.py @@ -369,7 +369,7 @@ class InOrOut: if not disp.has_dynamic_filename: if not disp.source_filename: raise CoverageException( - f"Plugin {plugin!r} didn't set source_filename for {disp.original_filename!r}" + f"Plugin {plugin!r} didn't set source_filename for '{disp.original_filename}'" ) reason = self.check_include_omit_etc(disp.source_filename, frame) if reason: diff --git a/coverage/parser.py b/coverage/parser.py index a3a41200..8d4e9ffb 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -41,7 +41,7 @@ class PythonParser: try: self.text = get_python_source(self.filename) except OSError as err: - raise NoSource(f"No source for code: {self.filename!r}: {err}") from err + raise NoSource(f"No source for code: '{self.filename}': {err}") from err self.exclude = exclude @@ -238,7 +238,7 @@ class PythonParser: else: lineno = err.args[1][0] # TokenError raise NotPython( - f"Couldn't parse {self.filename!r} as Python source: " + + f"Couldn't parse '{self.filename}' as Python source: " + f"{err.args[0]!r} at line {lineno}" ) from err diff --git a/coverage/sqldata.py b/coverage/sqldata.py index d27e12a2..db3ab73a 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -541,7 +541,7 @@ class CoverageData(SimpleReprMixin): file_id = self._file_id(filename) if file_id is None: raise CoverageException( - f"Can't add file tracer data for unmeasured file {filename!r}" + f"Can't add file tracer data for unmeasured file '{filename}'" ) existing_plugin = self.file_tracer(filename) |