diff options
-rw-r--r-- | bs4/testing.py | 23 | ||||
-rw-r--r-- | bs4/tests/test_html5lib.py | 6 |
2 files changed, 24 insertions, 5 deletions
diff --git a/bs4/testing.py b/bs4/testing.py index 6f9d857..55b953f 100644 --- a/bs4/testing.py +++ b/bs4/testing.py @@ -391,10 +391,29 @@ class XMLTreeBuilderSmokeTest(object): markup = '<root xmlns:a="http://example.com/" xmlns:b="http://example.net/"><a:foo>This tag is in the a namespace</a:foo><b:foo>This tag is in the b namespace</b:foo></root>' soup = self.soup(markup) root = soup.root - self.assertEquals("http://example.com/", root['xmlns:a']) - self.assertEquals("http://example.net/", root['xmlns:b']) + self.assertEqual("http://example.com/", root['xmlns:a']) + self.assertEqual("http://example.net/", root['xmlns:b']) +class HTML5TreeBuilderSmokeTest(HTMLTreeBuilderSmokeTest): + """Smoke test for a tree builder that supports HTML5.""" + + def test_html_tags_have_namespace(self): + markup = "<a>" + soup = self.soup(markup) + self.assertEqual("http://www.w3.org/1999/xhtml", soup.a.namespace) + + def test_svg_tags_have_namespace(self): + markup = '<svg>' + soup = self.soup(markup) + self.assertEqual("http://www.w3.org/2000/svg", soup.svg.namespace) + + def test_mathml_tags_have_namespace(self): + markup = '<math>' + soup = self.soup(markup) + self.assertEqual( + 'http://www.w3.org/1998/Math/MathML', soup.math.namespace) + def skipIf(condition, reason): def nothing(test, *args, **kwargs): diff --git a/bs4/tests/test_html5lib.py b/bs4/tests/test_html5lib.py index f1edddf..0828cfd 100644 --- a/bs4/tests/test_html5lib.py +++ b/bs4/tests/test_html5lib.py @@ -7,7 +7,7 @@ except ImportError, e: HTML5LIB_PRESENT = False from bs4.element import SoupStrainer from bs4.testing import ( - HTMLTreeBuilderSmokeTest, + HTML5TreeBuilderSmokeTest, SoupTest, skipIf, ) @@ -15,8 +15,8 @@ from bs4.testing import ( @skipIf( not HTML5LIB_PRESENT, "html5lib seems not to be present, not testing its tree builder.") -class HTML5LibBuilderSmokeTest(SoupTest, HTMLTreeBuilderSmokeTest): - """See ``HTMLTreeBuilderSmokeTest``.""" +class HTML5LibBuilderSmokeTest(SoupTest, HTML5TreeBuilderSmokeTest): + """See ``HTML5TreeBuilderSmokeTest``.""" @property def default_builder(self): |