Skip to content

Commit

Permalink
test corner cases
Browse files Browse the repository at this point in the history
  • Loading branch information
orsinium committed Apr 21, 2020
1 parent 1b4c703 commit acd8d1c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_linter/test_extractors/test_exceptions.py
Expand Up @@ -125,3 +125,22 @@ def f():
print(ast.dump(tree))
func_tree = tree.body[-1].body
tuple(get_exceptions(body=func_tree))


def test_inference_subcontracts():
text = """
@deal.raises(SomeError) # actual contract
@deal.raises(1) # ignore junk
@deal.post(lambda _: 1) # ignore other contracts
def subf():
return 1
@deal.raises(KeyError)
def f():
b = subf()
"""
tree = astroid.parse(dedent(text))
print(tree.repr_tree())
func_tree = tree.body[-1].body
returns = tuple(r.value for r in get_exceptions(body=func_tree))
assert returns == ('SomeError', )

0 comments on commit acd8d1c

Please sign in to comment.