diff --git a/poyo/patterns.py b/poyo/patterns.py index 199efcd..dad1cb6 100644 --- a/poyo/patterns.py +++ b/poyo/patterns.py @@ -19,7 +19,7 @@ _LIST_VALUE = ( _BLANK + r"-" + _BLANK + - r"('.*?'|\".*?\"|[^#]+?)" + + r"('.*?'|\".*?\"|[^#\n]+?)" + _INLINE_COMMENT + _OPT_NEWLINE ) _LIST_ITEM = _BLANK_LINE + r"|" + _COMMENT + r"|" + _LIST_VALUE diff --git a/tests/lists.yml b/tests/lists.yml new file mode 100644 index 0000000..5196814 --- /dev/null +++ b/tests/lists.yml @@ -0,0 +1,13 @@ +a: + - 1 + - 2 # comment between a and b +b: + - 3 + - 4 +c: + - 5 + - 6 +# comment between c and d +d: + - 7 + - 8 diff --git a/tests/test_parser.py b/tests/test_parser.py index 9565e64..9daf2f9 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -71,3 +71,26 @@ def test_parse_string_no_newline_list(string_data): }, } assert parse_string(string_data) == expected + + +@pytest.mark.parametrize('ymlfile', ['lists']) +def test_parse_string_lists(string_data): + expected = { + u'a': [ + 1, + 2, + ], + u'b': [ + 3, + 4, + ], + u'c': [ + 5, + 6, + ], + u'd': [ + 7, + 8, + ], + } + assert parse_string(string_data) == expected