diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2021-02-25 20:32:34 -0500 | 
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-02-25 20:32:34 -0500 | 
| commit | 198a11535b5065416c41e7fdc025718c1a92eff3 (patch) | |
| tree | 95ed70625ce48a1a55556b13fe84973359177a81 /tests/test_config.py | |
| parent | 1bdf48368c37bfe2de866e51133b240fda6eda36 (diff) | |
| download | python-coveragepy-git-198a11535b5065416c41e7fdc025718c1a92eff3.tar.gz | |
test: add a test of missing sections and options
Diffstat (limited to 'tests/test_config.py')
| -rw-r--r-- | tests/test_config.py | 12 | 
1 files changed, 12 insertions, 0 deletions
| diff --git a/tests/test_config.py b/tests/test_config.py index f400fc17..b1611c1b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -10,6 +10,7 @@ import mock  import pytest  import coverage +from coverage.config import HandyConfigParser  from coverage.misc import CoverageException  from tests.coveragetest import CoverageTest, UsingModulesMixin @@ -425,6 +426,17 @@ class ConfigTest(CoverageTest):          with pytest.raises(CoverageException, match=msg):              _ = coverage.Coverage() +    def test_exceptions_from_missing_things(self): +        self.make_file("config.ini", """\ +            [run] +            branch = True +            """) +        config = HandyConfigParser("config.ini") +        with pytest.raises(Exception, match="No section: 'xyzzy'"): +            config.options("xyzzy") +        with pytest.raises(Exception, match="No option 'foo' in section: 'xyzzy'"): +            config.get("xyzzy", "foo") +  class ConfigFileTest(UsingModulesMixin, CoverageTest):      """Tests of the config file settings in particular.""" | 
