diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2022-10-28 07:45:29 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2022-10-28 08:16:56 -0400 |
commit | b3a1d979f8625e4974eaa7211cdecb211ba90b50 (patch) | |
tree | acae62fba207edf0e55249e5b0a5f8c93abcee53 /coverage/tomlconfig.py | |
parent | 44fbd3b02ad22326767dc37fe3b94aa93b36e8a3 (diff) | |
download | python-coveragepy-git-b3a1d979f8625e4974eaa7211cdecb211ba90b50.tar.gz |
test: correct some config tests, and fully cover tomlconfig.py
Diffstat (limited to 'coverage/tomlconfig.py')
-rw-r--r-- | coverage/tomlconfig.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/coverage/tomlconfig.py b/coverage/tomlconfig.py index 0b5052b4..49282e92 100644 --- a/coverage/tomlconfig.py +++ b/coverage/tomlconfig.py @@ -3,7 +3,6 @@ """TOML configuration support for coverage.py""" -import configparser import os import re @@ -78,8 +77,6 @@ class TomlConfigParser: """ prefixes = ["tool.coverage."] - if self.our_file: - prefixes.append("") for prefix in prefixes: real_section = prefix + section parts = real_section.split(".") @@ -98,11 +95,11 @@ class TomlConfigParser: """Like .get, but returns the real section name and the value.""" name, data = self._get_section(section) if data is None: - raise configparser.NoSectionError(section) + raise ConfigError(f"No section: {section!r}") try: value = data[option] - except KeyError as exc: - raise configparser.NoOptionError(option, name) from exc + except KeyError: + raise ConfigError(f"No option {option!r} in section: {name!r}") from None return name, value def _get_single(self, section, option): @@ -129,7 +126,7 @@ class TomlConfigParser: def options(self, section): _, data = self._get_section(section) if data is None: - raise configparser.NoSectionError(section) + raise ConfigError(f"No section: {section!r}") return list(data.keys()) def get_section(self, section): |