Skip to content

Commit

Permalink
fix: correct previous refactorings
Browse files Browse the repository at this point in the history
File names should not be rendered with !r, since on Windows that will
produce double backslashes, which only confuses people.
  • Loading branch information
nedbat committed Jul 28, 2021
1 parent c5c1ba0 commit 7fe106b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion coverage/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions coverage/execfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def run(self):
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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion coverage/inorout.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def nope(disp, reason):
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:
Expand Down
4 changes: 2 additions & 2 deletions coverage/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, text=None, filename=None, exclude=None):
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

Expand Down Expand Up @@ -238,7 +238,7 @@ def parse_source(self):
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

Expand Down
2 changes: 1 addition & 1 deletion coverage/sqldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def add_file_tracers(self, file_tracers):
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)
Expand Down

0 comments on commit 7fe106b

Please # to comment.