summaryrefslogtreecommitdiff
path: root/bs4/tests/test_tree.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2012-03-15 11:08:02 -0400
committerLeonard Richardson <leonard.richardson@canonical.com>2012-03-15 11:08:02 -0400
commitc8eb3028cc509eb603e8b113c66f7c4eeee828b9 (patch)
tree91a76b2921d9ed4a1f37dfc9ac6765d65cb82759 /bs4/tests/test_tree.py
parent4b0975ed159bd789db6896da159f654229310701 (diff)
Fixed a bug where specifying 'text' while searching for a tag only worked if 'text' specified an exact string match. [bug=955942]
Diffstat (limited to 'bs4/tests/test_tree.py')
-rw-r--r--bs4/tests/test_tree.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py
index e9a5763..4d114b7 100644
--- a/bs4/tests/test_tree.py
+++ b/bs4/tests/test_tree.py
@@ -126,6 +126,18 @@ class TestFindAllByName(TreeTest):
self.assertSelects(
self.tree.find_all('a'), ['First tag.', 'Nested tag.'])
+ def test_find_all_by_name_and_text(self):
+ self.assertSelects(
+ self.tree.find_all('a', text='First tag.'), ['First tag.'])
+
+ self.assertSelects(
+ self.tree.find_all('a', text=True), ['First tag.', 'Nested tag.'])
+
+ self.assertSelects(
+ self.tree.find_all('a', text=re.compile("tag")),
+ ['First tag.', 'Nested tag.'])
+
+
def test_find_all_on_non_root_element(self):
# You can call find_all on any node, not just the root.
self.assertSelects(self.tree.c.find_all('a'), ['Nested tag.'])