summaryrefslogtreecommitdiff
path: root/bs4
diff options
context:
space:
mode:
Diffstat (limited to 'bs4')
-rw-r--r--bs4/element.py2
-rw-r--r--bs4/tests/test_soup.py5
2 files changed, 5 insertions, 2 deletions
diff --git a/bs4/element.py b/bs4/element.py
index d6ed020..2001ad5 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -45,7 +45,7 @@ def _alias(attr):
class NamespacedAttribute(unicode):
- def __new__(cls, prefix, name, namespace=None):
+ def __new__(cls, prefix, name=None, namespace=None):
if not name:
# This is the default namespace. Its name "has no value"
# per https://www.w3.org/TR/xml-names/#defaulting
diff --git a/bs4/tests/test_soup.py b/bs4/tests/test_soup.py
index 3603e81..dc88662 100644
--- a/bs4/tests/test_soup.py
+++ b/bs4/tests/test_soup.py
@@ -638,10 +638,13 @@ class TestUnicodeDammit(unittest.TestCase):
class TestNamedspacedAttribute(SoupTest):
- def test_name_may_be_none(self):
+ def test_name_may_be_none_or_missing(self):
a = NamespacedAttribute("xmlns", None)
self.assertEqual(a, "xmlns")
+ a = NamespacedAttribute("xmlns")
+ self.assertEqual(a, "xmlns")
+
def test_attribute_is_equivalent_to_colon_separated_string(self):
a = NamespacedAttribute("a", "b")
self.assertEqual("a:b", a)