From fe98e3d9ea4fb3806603d929ca853615150bb300 Mon Sep 17 00:00:00 2001 From: Francois Dang Ngoc Date: Thu, 2 Apr 2015 18:09:24 -0400 Subject: [PATCH] added more tests on unset values, bumped version and added new contributor @okdtsk --- CHANGELOG.md | 4 ++++ README.md | 1 + setup.py | 2 +- tests/test_config_parser.py | 20 ++++++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da7a229d..e0d92be5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Version 0.2.3 + +* fixed bug when we insert None values that shouldn't raise an exception when getting them. PR [#7] + ## Version 0.2.2 * simplified code (ConfigTree extends OrderedDict) and other features. PR [#6] diff --git a/README.md b/README.md index 2e8b92c3..fe1df98b 100644 --- a/README.md +++ b/README.md @@ -286,3 +286,4 @@ Java properties mapping | :x: - Aleksey Ostapenko ([@kbabka](https://github.com/kbakba)) - Martynas Mickevičius ([@2m](https://github.com/2m)) - Joe Halliwell ([@joehalliwell](https://github.com/joehalliwell)) + - Tasuku Okuda ([@okdtsk](https://github.com/okdtsk)) diff --git a/setup.py b/setup.py index ac30c066..fa47d0fb 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name='pyhocon', - version='0.2.2', + version='0.2.3', description='HOCON parser for Python', long_description='pyhocon is a HOCON parser for Python. Additionally we provide a tool (pyhocon) to convert any HOCON content into json, yaml and properties format.', keywords='hocon parser', diff --git a/tests/test_config_parser.py b/tests/test_config_parser.py index c685aee7..4b6b6928 100644 --- a/tests/test_config_parser.py +++ b/tests/test_config_parser.py @@ -1,4 +1,6 @@ +import pytest from pyhocon import ConfigFactory +from pyhocon.exceptions import ConfigMissingException class TestConfigParser(object): @@ -117,6 +119,24 @@ def test_parse_with_comments(self): assert config.get_string('a.b') == 'test' assert config.get('t') == [1, 2, 3] + def test_missing_config(self): + config = ConfigFactory.parse_string( + """ + a = 5 + """ + ) + # b is not set so show raise an exception + with pytest.raises(ConfigMissingException): + assert config.get('b') + + def test_parse_null(self): + config = ConfigFactory.parse_string( + """ + a = null + """ + ) + assert config.get('a') is None + def test_parse_empty(self): config = ConfigFactory.parse_string( """