polar: handle few more attributes defensively

This commit is contained in:
Dima Gerasimov 2020-05-15 13:17:02 +01:00
parent 8277b33c18
commit 65138808e7
2 changed files with 24 additions and 5 deletions

View file

@ -127,6 +127,7 @@ def wrap(j, throw=True) -> Iterator[Zoomable]:
for c in children:
if not c.this_consumed(): # TODO hmm. how does it figure out if it's consumed???
if throw:
# TODO need to keep a full path or something...
raise UnconsumedError(f'''
Expected {c} to be fully consumed by the parser.
'''.lstrip())
@ -175,6 +176,19 @@ def test_consume_all():
aaa['bbb'].consume_all()
def test_consume_few():
import pytest
pytest.skip('Will think about it later..')
with wrap({
'important': 123,
'unimportant': 'whatever'
}) as w:
w = cast(Wdict, w)
w['important'].zoom()
w.consume_all()
# TODO hmm, we want smth like this to work..
def test_zoom() -> None:
import pytest # type: ignore
with wrap({'aaa': 'whatever'}) as w: