From 49cc750524fb436fa4880eefa6c8d0b3bbbd7175 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Sat, 6 May 2017 13:23:18 -0400 Subject: It's now possible to use a tag's namespace prefix when searching, e.g. soup.find('namespace:tag') [bug=1655332] --- bs4/testing.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'bs4/testing.py') diff --git a/bs4/testing.py b/bs4/testing.py index 3a6ed42..733cc29 100644 --- a/bs4/testing.py +++ b/bs4/testing.py @@ -669,6 +669,30 @@ class XMLTreeBuilderSmokeTest(object): soup = self.soup(markup) self.assertEqual(unicode(soup.foo), markup) + def test_find_by_prefixed_name(self): + doc = """ +foo + bar + baz + +""" + soup = self.soup(doc) + + # There are three tags. + self.assertEqual(3, len(soup.find_all('tag'))) + + # But two of them are ns1:tag and one of them is ns2:tag. + self.assertEqual(2, len(soup.find_all('ns1:tag'))) + self.assertEqual(1, len(soup.find_all('ns2:tag'))) + + self.assertEqual(1, len(soup.find_all('ns2:tag', key='value'))) + self.assertEqual(3, len(soup.find_all(['ns1:tag', 'ns2:tag']))) + + + class HTML5TreeBuilderSmokeTest(HTMLTreeBuilderSmokeTest): """Smoke test for a tree builder that supports HTML5.""" -- cgit v1.2.3