Skip to content

Commit 7fe106b

Browse files
committed
fix: correct previous refactorings
File names should not be rendered with !r, since on Windows that will produce double backslashes, which only confuses people.
1 parent c5c1ba0 commit 7fe106b

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

coverage/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def combine_parallel_data(data, aliases=None, data_paths=None, strict=False, kee
9191
pattern = os.path.join(os.path.abspath(p), localdot)
9292
files_to_combine.extend(glob.glob(pattern))
9393
else:
94-
raise CoverageException(f"Couldn't combine from non-existent path {p!r}")
94+
raise CoverageException(f"Couldn't combine from non-existent path '{p}'")
9595

9696
if strict and not files_to_combine:
9797
raise CoverageException("No data to combine")

coverage/execfile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ def run(self):
192192
except CoverageException:
193193
raise
194194
except Exception as exc:
195-
msg = "Couldn't run '{filename}' as Python code: {exc.__class__.__name__}: {exc}"
196-
raise CoverageException(msg.format(filename=self.arg0, exc=exc)) from exc
195+
msg = f"Couldn't run '{self.arg0}' as Python code: {exc.__class__.__name__}: {exc}"
196+
raise CoverageException(msg) from exc
197197

198198
# Execute the code object.
199199
# Return to the original directory in case the test code exits in
@@ -278,7 +278,7 @@ def make_code_from_py(filename):
278278
try:
279279
source = get_python_source(filename)
280280
except (OSError, NoSource) as exc:
281-
raise NoSource(f"No file to run: {filename!r}") from exc
281+
raise NoSource(f"No file to run: '{filename}'") from exc
282282

283283
code = compile_unicode(source, filename, "exec")
284284
return code
@@ -289,7 +289,7 @@ def make_code_from_pyc(filename):
289289
try:
290290
fpyc = open(filename, "rb")
291291
except OSError as exc:
292-
raise NoCode(f"No file to run: {filename!r}") from exc
292+
raise NoCode(f"No file to run: '{filename}'") from exc
293293

294294
with fpyc:
295295
# First four bytes are a version-specific magic number. It has to

coverage/inorout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def nope(disp, reason):
369369
if not disp.has_dynamic_filename:
370370
if not disp.source_filename:
371371
raise CoverageException(
372-
f"Plugin {plugin!r} didn't set source_filename for {disp.original_filename!r}"
372+
f"Plugin {plugin!r} didn't set source_filename for '{disp.original_filename}'"
373373
)
374374
reason = self.check_include_omit_etc(disp.source_filename, frame)
375375
if reason:

coverage/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, text=None, filename=None, exclude=None):
4141
try:
4242
self.text = get_python_source(self.filename)
4343
except OSError as err:
44-
raise NoSource(f"No source for code: {self.filename!r}: {err}") from err
44+
raise NoSource(f"No source for code: '{self.filename}': {err}") from err
4545

4646
self.exclude = exclude
4747

@@ -238,7 +238,7 @@ def parse_source(self):
238238
else:
239239
lineno = err.args[1][0] # TokenError
240240
raise NotPython(
241-
f"Couldn't parse {self.filename!r} as Python source: " +
241+
f"Couldn't parse '{self.filename}' as Python source: " +
242242
f"{err.args[0]!r} at line {lineno}"
243243
) from err
244244

coverage/sqldata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def add_file_tracers(self, file_tracers):
541541
file_id = self._file_id(filename)
542542
if file_id is None:
543543
raise CoverageException(
544-
f"Can't add file tracer data for unmeasured file {filename!r}"
544+
f"Can't add file tracer data for unmeasured file '{filename}'"
545545
)
546546

547547
existing_plugin = self.file_tracer(filename)

0 commit comments

Comments
 (0)