From 436939628ff1c5bbc37d5c91c4a7c68d83f12f49 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Fri, 6 Nov 2020 21:03:04 -0300 Subject: Add optional subvalues --- testing/test_abdl.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'testing') diff --git a/testing/test_abdl.py b/testing/test_abdl.py index d28658a..79a0edf 100644 --- a/testing/test_abdl.py +++ b/testing/test_abdl.py @@ -262,6 +262,13 @@ def test_empty(foo, pat): yield {} assert all(LogAndCompare(pat.match(foo), deep(foo))) +def test_optional_value_subtree(): + pat = abdl.compile("(->foo'foo'?)?(->bar'bar')") + matcher = pat.match({'foo': 1, 'bar': 2}) + assert list(matcher) == [{'foo': ('foo', 1), 'bar': ('bar', 2)}] + matcher = pat.match({'bar': 2}) + assert list(matcher) == [{'bar': ('bar', 2)}] + # FIXME #@hypothesis.given(objtree, st.text()) #def test_exhaustive(foo, pat): -- cgit 1.4.1