# Path: mako/testing/_config.py
# class ConfigValueTypeError(ConfigError):
#     pass
# 
# Path: mako/testing/_config.py
# class MissingConfig(ConfigError):
#     pass
# 
# Path: mako/testing/_config.py
# class MissingConfigItem(ConfigError):
#     pass
# 
# Path: mako/testing/_config.py
# class MissingConfigSection(ConfigError):
#     pass
# 
# Path: mako/testing/_config.py
# class ReadsCfg:
#     section_header: ClassVar[str]
#     converters: ClassVar[Optional[dict]] = None
# 
#     @classmethod
#     def from_cfg_file(cls, filespec: Union[Path, str]):
#         cfg = _parse_cfg_file(filespec)
#         dispatch = _build_getter_dispatch(
#             cfg, cls.section_header, converters=cls.converters
#         )
#         kwargs = {
#             field.name: dispatch.get_typed_value(field.type, field.name)
#             for field in dataclasses.fields(cls)
#         }
#         return cls(**kwargs)
# 
# Path: mako/testing/assertions.py
# def assert_raises_message_with_given_cause(
#     except_cls, msg, cause_cls, callable_, *args, **kwargs
# ):
#     return _assert_raises(
#         except_cls, callable_, args, kwargs, msg=msg, cause_cls=cause_cls
#     )
# 
# Path: mako/testing/assertions.py
# def assert_raises_with_given_cause(
#     except_cls, cause_cls, callable_, *args, **kw
# ):
#     return _assert_raises(except_cls, callable_, args, kw, cause_cls=cause_cls)


import configparser
import pytest
from dataclasses import dataclass
from datetime import datetime
from decimal import Decimal
from pathlib import Path
from mako.testing._config import ConfigValueTypeError
from mako.testing._config import MissingConfig
from mako.testing._config import MissingConfigItem
from mako.testing._config import MissingConfigSection
from mako.testing._config import ReadsCfg
from mako.testing.assertions import assert_raises_message_with_given_cause
from mako.testing.assertions import assert_raises_with_given_cause

    section_header = "missing_item"


class BasicConfigTest:
    @pytest.fixture(scope="class")
    def config(self):
        return BasicConfig.from_cfg_file(PATH_TO_TEST_CONFIG)

    def test_coercions(self, config):
        assert isinstance(config.int_value, int)
        assert isinstance(config.bool_value, bool)
        assert isinstance(config.float_value, float)
        assert isinstance(config.str_value, str)

    def test_values(self, config):
        assert config.int_value == 15421
        assert config.bool_value == True
        assert config.float_value == 14.01
        assert config.str_value == "Ceci n'est pas une chaîne"

    def test_error_on_loading_from_nonexistent_file(self):
        assert_raises_with_given_cause(
            MissingConfig,
            FileNotFoundError,
            BasicConfig.from_cfg_file,
            "./n/o/f/i/l/e/h.ere",
        )

    def test_error_on_loading_from_nonexistent_section(self):

# Path: mako/testing/_config.py
# class ConfigValueTypeError(ConfigError):
#     pass
# 
# Path: mako/testing/_config.py
# class MissingConfig(ConfigError):
#     pass
# 
# Path: mako/testing/_config.py
# class MissingConfigItem(ConfigError):
#     pass
# 
# Path: mako/testing/_config.py
# class MissingConfigSection(ConfigError):
#     pass
# 
# Path: mako/testing/_config.py
# class ReadsCfg:
#     section_header: ClassVar[str]
#     converters: ClassVar[Optional[dict]] = None
# 
#     @classmethod
#     def from_cfg_file(cls, filespec: Union[Path, str]):
#         cfg = _parse_cfg_file(filespec)
#         dispatch = _build_getter_dispatch(
#             cfg, cls.section_header, converters=cls.converters
#         )
#         kwargs = {
#             field.name: dispatch.get_typed_value(field.type, field.name)
#             for field in dataclasses.fields(cls)
#         }
#         return cls(**kwargs)
# 
# Path: mako/testing/assertions.py
# def assert_raises_message_with_given_cause(
#     except_cls, msg, cause_cls, callable_, *args, **kwargs
# ):
#     return _assert_raises(
#         except_cls, callable_, args, kwargs, msg=msg, cause_cls=cause_cls
#     )
# 
# Path: mako/testing/assertions.py
# def assert_raises_with_given_cause(
#     except_cls, cause_cls, callable_, *args, **kw
# ):
#     return _assert_raises(except_cls, callable_, args, kw, cause_cls=cause_cls)


# Path: test/testing/test_config.py
import configparser
import pytest
from dataclasses import dataclass
from datetime import datetime
from decimal import Decimal
from pathlib import Path
from mako.testing._config import ConfigValueTypeError
from mako.testing._config import MissingConfig
from mako.testing._config import MissingConfigItem
from mako.testing._config import MissingConfigSection
from mako.testing._config import ReadsCfg
from mako.testing.assertions import assert_raises_message_with_given_cause
from mako.testing.assertions import assert_raises_with_given_cause


    section_header = "missing_item"


class BasicConfigTest:
    @pytest.fixture(scope="class")
    def config(self):
        return BasicConfig.from_cfg_file(PATH_TO_TEST_CONFIG)

    def test_coercions(self, config):
        assert isinstance(config.int_value, int)
        assert isinstance(config.bool_value, bool)
        assert isinstance(config.float_value, float)
        assert isinstance(config.str_value, str)

    def test_values(self, config):
        assert config.int_value == 15421
        assert config.bool_value == True
        assert config.float_value == 14.01
        assert config.str_value == "Ceci n'est pas une chaîne"

    def test_error_on_loading_from_nonexistent_file(self):
        assert_raises_with_given_cause(
            MissingConfig,
            FileNotFoundError,
            BasicConfig.from_cfg_file,
            "./n/o/f/i/l/e/h.ere",
        )

    def test_error_on_loading_from_nonexistent_section(self):

        assert_raises_with_given_cause(