# 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
        return UnsupportedTypesConfig.from_cfg_file(PATH_TO_TEST_CONFIG)

    def test_values(self, config):
        assert config.decimal_value == "100001.01"
        assert config.datetime_value == "2021-12-04 00:05:23.283"


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

    def test_values(self, config):
        assert config.decimal_value == Decimal("100001.01")
        assert config.datetime_value == datetime(2021, 12, 4, 0, 5, 23, 283000)


class TypeMismatchConfigTest:
    def test_error_on_load(self):
        assert_raises_message_with_given_cause(
            ConfigValueTypeError,
            "Wrong value type for int_value",
            ValueError,
            TypeMismatchConfig.from_cfg_file,
            PATH_TO_TEST_CONFIG,
        )


class MissingItemConfigTest:
    def test_error_on_load(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

        return UnsupportedTypesConfig.from_cfg_file(PATH_TO_TEST_CONFIG)

    def test_values(self, config):
        assert config.decimal_value == "100001.01"
        assert config.datetime_value == "2021-12-04 00:05:23.283"


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

    def test_values(self, config):
        assert config.decimal_value == Decimal("100001.01")
        assert config.datetime_value == datetime(2021, 12, 4, 0, 5, 23, 283000)


class TypeMismatchConfigTest:
    def test_error_on_load(self):
        assert_raises_message_with_given_cause(
            ConfigValueTypeError,
            "Wrong value type for int_value",
            ValueError,
            TypeMismatchConfig.from_cfg_file,
            PATH_TO_TEST_CONFIG,
        )


class MissingItemConfigTest:
    def test_error_on_load(self):

        assert_raises_message_with_given_cause(