summaryrefslogtreecommitdiff
path: root/bs4/tests
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2012-02-15 14:07:04 -0500
committerLeonard Richardson <leonard.richardson@canonical.com>2012-02-15 14:07:04 -0500
commitbe0c08585f54ec709740ff4352006bf3e605b8f2 (patch)
tree342c8a482bef4490a8f0fbb528611888bcf76721 /bs4/tests
parent0f6d3cfbef6fc0b90f0e9fbe58408e00c2383070 (diff)
Better defined behavior when the user wants to search for a combination of text and tag-specific arguments. [bug=695312]
Diffstat (limited to 'bs4/tests')
-rw-r--r--bs4/tests/test_tree.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py
index 4da6fd9..2e74c00 100644
--- a/bs4/tests/test_tree.py
+++ b/bs4/tests/test_tree.py
@@ -277,6 +277,27 @@ class TestFindAllByAttribute(TreeTest):
self.assertSelects(tree.find_all(id=re.compile("^a+$")),
["One a.", "Two as."])
+ def test_find_by_name_and_containing_string(self):
+ soup = self.soup("<b>foo</b><b>bar</b><a>foo</a>")
+ a = soup.a
+
+ self.assertEqual([a], soup.find_all("a", text="foo"))
+ self.assertEqual([], soup.find_all("a", text="bar"))
+ self.assertEqual([], soup.find_all("a", text="bar"))
+
+ def test_find_by_name_and_containing_string_when_string_is_buried(self):
+ soup = self.soup("<a>foo</a><a><b><c>foo</c></b></a>")
+ self.assertEqual(soup.find_all("a"), soup.find_all("a", text="foo"))
+
+ def test_find_by_attribute_and_containing_string(self):
+ soup = self.soup('<b id="1">foo</b><a id="2">foo</a>')
+ a = soup.a
+
+ self.assertEqual([a], soup.find_all(id=2, text="foo"))
+ self.assertEqual([], soup.find_all(id=1, text="bar"))
+
+
+
class TestIndex(TreeTest):
"""Test Tag.index"""