Skip to content

Commit

Permalink
[fix] this test will behave badly when it test a NodeList that is emp…
Browse files Browse the repository at this point in the history
…ty, it will fail on it while it should succed
  • Loading branch information
Psycojoker committed Mar 10, 2016
1 parent a61d209 commit 5745992
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions redbaron.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,14 +660,14 @@ def find(self, identifier, *args, **kwargs):
continue

found = i.find(identifier, *args, **kwargs)
if found:
if found is not None:
return found

elif kind == "list":
attr = getattr(self, key).node_list if isinstance(getattr(self, key), ProxyList) else getattr(self, key)
for i in attr:
found = i.find(identifier, *args, **kwargs)
if found:
if found is not None:
return found

else:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_initial_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,3 +727,8 @@ def test_insert_after_offset():
red = RedBaron("a = 1\nprint(pouet)\n")
red[0].insert_after("chocolat", offset=1)
assert red.dumps() == "a = 1\nprint(pouet)\nchocolat\n"


def test_regression_find_empty_call():
red = RedBaron("a()")
assert red.find("call") is red[0][1]

0 comments on commit 5745992

Please sign in to comment.