summaryrefslogtreecommitdiff
path: root/bs4/testing.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2018-07-18 19:04:36 -0400
committerLeonard Richardson <leonardr@segfault.org>2018-07-18 19:04:36 -0400
commit68b55626839a8a0ea9e750fff546e201d144f96c (patch)
tree5a6acd307e3098dcaad17f4a930e48de09ba96ed /bs4/testing.py
parent75c81928902b3f2896cbd3482a59828965627916 (diff)
Preserve XML namespaces when they are introduced inside an XML
document, not just the ones introduced at the top level. [bug=1718787]
Diffstat (limited to 'bs4/testing.py')
-rw-r--r--bs4/testing.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/bs4/testing.py b/bs4/testing.py
index 9d42702..641663c 100644
--- a/bs4/testing.py
+++ b/bs4/testing.py
@@ -624,6 +624,17 @@ class XMLTreeBuilderSmokeTest(object):
self.assertEqual(
soup.encode("utf-8"), markup)
+ def test_nested_namespaces(self):
+ doc = """<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<parent xmlns="http://ns1/">
+<child xmlns="http://ns2/" xmlns:ns3="http://ns3/">
+<grandchild ns3:attr="value" xmlns="http://ns4/"/>
+</child>
+</parent>"""
+ soup = BeautifulSoup(doc, "lxml-xml")
+ self.assertEqual(doc, soup.encode())
+
def test_formatter_processes_script_tag_for_xml_documents(self):
doc = """
<script type="text/javascript">