diff options
author | Leonard Richardson <leonardr@segfault.org> | 2017-05-07 08:18:48 -0400 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2017-05-07 08:18:48 -0400 |
commit | 77f1bf0efe0142d5ad5ce84e09a364580a8b6743 (patch) | |
tree | a5b201b654eb3e8d93286ad3e999af19221315c0 /bs4/testing.py | |
parent | 98a2e39b6d4bd9cad8a1c19110124e33e9ae4e54 (diff) |
Namespace prefix is preserved when an XML tag is copied. Thanks
to Vikas for a patch and test. [bug=1685172]
Diffstat (limited to 'bs4/testing.py')
-rw-r--r-- | bs4/testing.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/bs4/testing.py b/bs4/testing.py index 40ccac6..6ba2506 100644 --- a/bs4/testing.py +++ b/bs4/testing.py @@ -710,8 +710,18 @@ class XMLTreeBuilderSmokeTest(object): self.assertEqual(1, len(soup.find_all('ns2:tag', key='value'))) self.assertEqual(3, len(soup.find_all(['ns1:tag', 'ns2:tag']))) + def test_copy_tag_preserves_namespace(self): + xml = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<w:document xmlns:w="http://example.com/ns0"/>""" + + soup = self.soup(xml) + tag = soup.document + duplicate = copy.copy(tag) + + # The two tags have the same namespace prefix. + self.assertEqual(tag.prefix, duplicate.prefix) + - class HTML5TreeBuilderSmokeTest(HTMLTreeBuilderSmokeTest): """Smoke test for a tree builder that supports HTML5.""" |