Skip to content

Commit

Permalink
new _config.py coverage to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
koiker committed Apr 27, 2021
1 parent ffcb95c commit 26127d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cfn_tools/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class _ConfigArg(NamedTuple):
class _Config:
"""Cfn_flip's Configuration class."""

__slots__ = (f"_{attr}" for attr in _CONFIG_DEFAULTS)
# __slots__ = (f"_{attr}" for attr in _CONFIG_DEFAULTS)

def __init__(self):
for name, conf in _CONFIG_DEFAULTS.items():
Expand Down
15 changes: 14 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
import os
import pytest
from cfn_tools._config import config, apply_configs
from cfn_tools._config import config, apply_configs, _CONFIG_DEFAULTS, _ConfigArg, _Config


def test_config_rest():
Expand Down Expand Up @@ -49,3 +49,16 @@ def test_config_apply_configs():
def temp_my_func(max_col_width):
return max_col_width
assert temp_my_func() == 200


def test_config_apply_type_null():
_CONFIG_DEFAULTS['test_nullable'] = _ConfigArg(dtype=bool, nullable=True, has_default=False)
test_config = _Config()
test_config.test_nullable = None
assert test_config.test_nullable is None


def test_config_apply_type_null_error():
_CONFIG_DEFAULTS['test_nullable'] = _ConfigArg(dtype=int, nullable=False, has_default=True, default="nil")
with pytest.raises(ValueError):
_ = _Config()

0 comments on commit 26127d0

Please sign in to comment.