Skip to content

Commit 2da8c20

Browse files
committed
debug #1516
1 parent 012a687 commit 2da8c20

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

coverage/config.py

+10
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,15 @@ def from_file(self, filename: str, warn: Callable[[str], None], our_file: bool)
291291
else:
292292
cp = HandyConfigParser(our_file)
293293

294+
print(f"{cp=}")
294295
self.attempted_config_files.append(filename)
295296

296297
try:
297298
files_read = cp.read(filename)
298299
except (configparser.Error, TomlDecodeError) as err:
300+
print(f"{err=}")
299301
raise ConfigError(f"Couldn't read config file {filename}: {err}") from err
302+
print(f"{files_read=}")
300303
if not files_read:
301304
return False
302305

@@ -308,6 +311,7 @@ def from_file(self, filename: str, warn: Callable[[str], None], our_file: bool)
308311
was_set = self._set_attr_from_config_option(cp, *option_spec)
309312
if was_set:
310313
any_set = True
314+
print(f"{any_set=} because {option_spec=}")
311315
except ValueError as err:
312316
raise ConfigError(f"Couldn't read config file {filename}: {err}") from err
313317

@@ -332,20 +336,24 @@ def from_file(self, filename: str, warn: Callable[[str], None], our_file: bool)
332336
for option in cp.options('paths'):
333337
self.paths[option] = cp.getlist('paths', option)
334338
any_set = True
339+
print(f"{any_set=} because paths:{option}")
335340

336341
# plugins can have options
337342
for plugin in self.plugins:
338343
if cp.has_section(plugin):
339344
self.plugin_options[plugin] = cp.get_section(plugin)
340345
any_set = True
346+
print(f"{any_set=} because {plugin=}:{option}")
341347

342348
# Was this file used as a config file? If it's specifically our file,
343349
# then it was used. If we're piggybacking on someone else's file,
344350
# then it was only used if we found some settings in it.
351+
print(f"{our_file=}")
345352
if our_file:
346353
used = True
347354
else:
348355
used = any_set
356+
print(f"{used=}")
349357

350358
if used:
351359
self.config_file = os.path.abspath(filename)
@@ -591,7 +599,9 @@ def read_coverage_config(
591599
files_to_try = config_files_to_try(config_file)
592600

593601
for fname, our_file, specified_file in files_to_try:
602+
print(f"Reading {fname=}")
594603
config_read = config.from_file(fname, warn, our_file=our_file)
604+
print(f"{config_read=}")
595605
if config_read:
596606
break
597607
if specified_file:

coverage/tomlconfig.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ def read(self, filenames):
4343
try:
4444
with open(filename, encoding='utf-8') as fp:
4545
toml_text = fp.read()
46-
except OSError:
46+
except OSError as err:
47+
print(f"OSError {err=}")
4748
return []
49+
print(f"{tomllib=}")
4850
if tomllib is not None:
4951
try:
5052
self.data = tomllib.loads(toml_text)
5153
except tomllib.TOMLDecodeError as err:
54+
print(f"TomlDecodeError {err=}")
5255
raise TomlDecodeError(str(err)) from err
5356
return [filename]
5457
else:

0 commit comments

Comments
 (0)