From 3ad71fceec0002be87306174f0b2464cc2342a7e Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Mon, 6 May 2013 17:56:35 -0400 Subject: Fix a bug by which keyword arguments to find_parent() were not being passed on. [bug=1126734] --- NEWS.txt | 3 +++ bs4/element.py | 2 +- bs4/tests/test_tree.py | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS.txt b/NEWS.txt index 9f8b3dc..8560541 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -10,6 +10,9 @@ * Fix a bug in the lxml treebuilder which crashed when a tag included an attribute from the predefined "xml:" namespace. [bug=1065617] +* Fix a bug by which keyword arguments to find_parent() were not + being passed on. [bug=1126734] + = 4.1.3 (20120820) = * Skipped a test under Python 2.6 and Python 3.1 to avoid a spurious diff --git a/bs4/element.py b/bs4/element.py index bc6d9c8..77c8da0 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -436,7 +436,7 @@ class PageElement(object): # NOTE: We can't use _find_one because findParents takes a different # set of arguments. r = None - l = self.find_parents(name, attrs, 1) + l = self.find_parents(name, attrs, 1, **kwargs) if l: r = l[0] return r diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py index a4e2a8a..a5e761f 100644 --- a/bs4/tests/test_tree.py +++ b/bs4/tests/test_tree.py @@ -425,6 +425,7 @@ class TestParentOperations(TreeTest): def test_find_parent(self): self.assertEqual(self.start.find_parent('ul')['id'], 'bottom') + self.assertEqual(self.start.find_parent('ul', id='top')['id'], 'top') def test_parent_of_text_element(self): text = self.tree.find(text="Start here") -- cgit v1.2.3