diff options
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | beautifulsoup/element.py | 7 | ||||
-rw-r--r-- | tests/test_tree.py | 6 |
3 files changed, 9 insertions, 6 deletions
@@ -7,6 +7,8 @@ work. Here are the renames: * findAll -> find_all * findNext -> find_next + * findAllNext -> find_all_next + * findAllPrevious -> find_all_previous == Generators are now properties == diff --git a/beautifulsoup/element.py b/beautifulsoup/element.py index 082c71b..00b72b6 100644 --- a/beautifulsoup/element.py +++ b/beautifulsoup/element.py @@ -192,15 +192,16 @@ class PageElement: def findPrevious(self, name=None, attrs={}, text=None, **kwargs): """Returns the first item that matches the given criteria and appears before this Tag in the document.""" - return self._findOne(self.find_allPrevious, name, attrs, text, **kwargs) + return self._findOne(self.find_all_previous, name, attrs, text, **kwargs) - def find_allPrevious(self, name=None, attrs={}, text=None, limit=None, + def find_all_previous(self, name=None, attrs={}, text=None, limit=None, **kwargs): """Returns all items that match the given criteria and appear before this Tag in the document.""" return self._find_all(name, attrs, text, limit, self.previous_elements, **kwargs) - fetchPrevious = find_allPrevious # Compatibility with pre-3.x + findAllPrevious = find_all_previous # Compatibility with BS3 + fetchPrevious = find_all_previous # Compatibility with BS2 def findPreviousSibling(self, name=None, attrs={}, text=None, **kwargs): """Returns the closest sibling to this Tag that matches the diff --git a/tests/test_tree.py b/tests/test_tree.py index 86272bb..d2361cb 100644 --- a/tests/test_tree.py +++ b/tests/test_tree.py @@ -369,8 +369,8 @@ class TestPreviousOperations(ProximityTest): # of the "Three" node itself, which is why "Three" shows up # here. self.assertSelects( - self.end.find_allPrevious('b'), ["Three", "Two", "One"]) - self.assertSelects(self.end.find_allPrevious(id=1), ["One"]) + self.end.find_all_previous('b'), ["Three", "Two", "One"]) + self.assertSelects(self.end.find_all_previous(id=1), ["One"]) def test_find_previous(self): self.assertEquals(self.end.findPrevious('b')['id'], '3') @@ -380,7 +380,7 @@ class TestPreviousOperations(ProximityTest): text = self.tree.find(text="Three") self.assertEquals(text.findPrevious("b").string, "Three") self.assertSelects( - text.find_allPrevious("b"), ["Three", "Two", "One"]) + text.find_all_previous("b"), ["Three", "Two", "One"]) def test_previous_generator(self): start = self.tree.find(text="One") |