Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ElementList.__getattr__() to no longer hide ElementNotFound #707

Merged
merged 1 commit into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion splinter/element_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def is_empty(self):
def __getattr__(self, name):
try:
return getattr(self.first, name)
except (ElementDoesNotExist, AttributeError):
except AttributeError:
try:
return getattr(self._container, name)
except AttributeError:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_element_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ def test_raise_attribute_error(self):
the_list = ElementList([Person(), Person()])
the_list.talk()

def test_attribute_error_for_empty(self):
def test_attribute_error_method_for_empty(self):
"""
should raise AttributeError when the list is empty
and someone tries to access a method or property on it
should raise ElementDoesNotExist when the list is empty
and someone tries to access a method or property on the child element.
"""
with self.assertRaises(AttributeError):
with self.assertRaises(ElementDoesNotExist):
the_list = ElementList([])
the_list.unknown_method()

Expand Down