diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2020-11-06 22:25:12 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2020-11-06 22:25:12 -0300 |
commit | ff3628c36eab5ec19ab850e9126a951f5c203568 (patch) | |
tree | d05f7bf27b0141f779a013bcfa22a16543b33c18 /testing | |
parent | 436939628ff1c5bbc37d5c91c4a7c68d83f12f49 (diff) |
Fix subvalue not parsing predicates
Diffstat (limited to 'testing')
-rw-r--r-- | testing/test_abdl.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/testing/test_abdl.py b/testing/test_abdl.py index 79a0edf..4b151b0 100644 --- a/testing/test_abdl.py +++ b/testing/test_abdl.py @@ -269,6 +269,22 @@ def test_optional_value_subtree(): matcher = pat.match({'bar': 2}) assert list(matcher) == [{'bar': ('bar', 2)}] +def test_predicate_on_subvalue(): + # make sure predicates on subvalues compile + pat = abdl.compile("(:?$dict->foo'foo'?)?(->bar'bar')", dict(dict=dict)) + 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)}] + try: + # this should fail on the 'bar' match + next(pat.match([]), None) + except abdl.exceptions.ValidationError: + # but we don't really have a way of checking which part failed + pass + else: + assert False + # FIXME #@hypothesis.given(objtree, st.text()) #def test_exhaustive(foo, pat): |