summaryrefslogtreecommitdiff
path: root/bs4/testing.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2012-02-23 10:55:39 -0500
committerLeonard Richardson <leonard.richardson@canonical.com>2012-02-23 10:55:39 -0500
commit328204928bd22ca9e8aeac0a3208645d9f82f264 (patch)
treef3887c29a818d484834b28fd1569f17084b52dee /bs4/testing.py
parenta4ffd587fad7d2442a9ccdcdd0a8f6df347f39eb (diff)
Added basic namespace tests.
Diffstat (limited to 'bs4/testing.py')
-rw-r--r--bs4/testing.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/bs4/testing.py b/bs4/testing.py
index cc30e17..dc20812 100644
--- a/bs4/testing.py
+++ b/bs4/testing.py
@@ -198,6 +198,21 @@ class HTMLTreeBuilderSmokeTest(object):
self.assertSoupEquals("&#x10000000000000;", expect)
self.assertSoupEquals("&#1000000000;", expect)
+ def test_basic_namespaces(self):
+ """Parsers don't need to *understand* namespaces, but at the
+ very least they should not choke on namespaces or lose
+ data."""
+
+ markup = b'<html xmlns="http://www.w3.org/1999/xhtml" xmlns:mathml="http://www.w3.org/1998/Math/MathML" xmlns:svg="http://www.w3.org/2000/svg"><head></head><body><mathml:msqrt>4</mathml:msqrt><b svg:fill="red"></b></body></html>'
+ soup = self.soup(markup)
+ self.assertEquals(markup, soup.encode())
+ html = soup.html
+ self.assertEquals('http://www.w3.org/1999/xhtml', soup.html['xmlns'])
+ self.assertEquals(
+ 'http://www.w3.org/1998/Math/MathML', soup.html['xmlns:mathml'])
+ self.assertEquals(
+ 'http://www.w3.org/2000/svg', soup.html['xmlns:svg'])
+
#
# Generally speaking, tests below this point are more tests of
# Beautiful Soup than tests of the tree builders. But parsers are