Skip to content

Commit

Permalink
fix for #324 (#326)
Browse files Browse the repository at this point in the history
dates were not correctly parsed with recent versions of pyparsing because of usage of White()
  • Loading branch information
pierresouchay authored May 27, 2024
1 parent 11e00fd commit dbed4b1
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/test_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,27 @@ def test_parse_with_enclosing_brace(self):

assert config.get_string('a.b') == '5'

def test_parse_with_enclosing_brace_and_period_like_value(self):
config = ConfigFactory.parse_string(
"""
{
a: {
b: 5
y_min: 42
}
}
"""
)

assert config.get_string('a.b') == '5'
assert config.get_string('a.y_min') == '42'


def test_issue_324(self):
config = ConfigFactory.parse_string("a { c = 3\nd = 4 }")
assert config["a"]["c"] == 3
assert config["a"]["d"] == 4

@pytest.mark.parametrize('data_set', [
('a: 1 minutes', period(minutes=1)),
('a: 1minutes', period(minutes=1)),
Expand Down Expand Up @@ -168,7 +189,14 @@ def test_parse_with_list_mixed_types_with_durations_and_trailing_comma(self):
c: bar
"""
)
assert config['b'] == ['a', 1, period(weeks=10), period(minutes=5)]
# Depending if parsing dates is enabled, might parse date or might not
# since this is an optional dependency
assert (
config['b'] == ['a', 1, period(weeks=10), period(minutes=5)]
) or (
config['b'] == ['a', 1, '10 weeks', '5 minutes']
)


def test_parse_with_enclosing_square_bracket(self):
config = ConfigFactory.parse_string("[1, 2, 3]")
Expand Down

0 comments on commit dbed4b1

Please sign in to comment.