summaryrefslogtreecommitdiff
path: root/bs4/tests
diff options
context:
space:
mode:
Diffstat (limited to 'bs4/tests')
-rw-r--r--bs4/tests/test_soup.py4
-rw-r--r--bs4/tests/test_tree.py17
2 files changed, 20 insertions, 1 deletions
diff --git a/bs4/tests/test_soup.py b/bs4/tests/test_soup.py
index 8333ad4..33ab0fa 100644
--- a/bs4/tests/test_soup.py
+++ b/bs4/tests/test_soup.py
@@ -240,6 +240,10 @@ class TestUnicodeDammit(unittest.TestCase):
class TestNamedspacedAttribute(SoupTest):
+ def test_name_may_be_none(self):
+ a = NamespacedAttribute("xmlns", None)
+ self.assertEqual(a, "xmlns")
+
def test_attribute_is_equivalent_to_colon_separated_string(self):
a = NamespacedAttribute("a", "b")
self.assertEqual("a:b", a)
diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py
index ce9a7ec..c75b561 100644
--- a/bs4/tests/test_tree.py
+++ b/bs4/tests/test_tree.py
@@ -18,7 +18,13 @@ from bs4.builder import (
builder_registry,
HTMLParserTreeBuilder,
)
-from bs4.element import CData, NavigableString, SoupStrainer, Tag
+from bs4.element import (
+ CData,
+ Doctype,
+ NavigableString,
+ SoupStrainer,
+ Tag,
+)
from bs4.testing import (
SoupTest,
skipIf,
@@ -1277,3 +1283,12 @@ class TestNavigableStringSubclasses(SoupTest):
self.assertEqual(str(soup), "<![CDATA[foo]]>")
self.assertEqual(soup.find(text="foo"), "foo")
self.assertEqual(soup.contents[0], "foo")
+
+ def test_doctype_ends_in_newline(self):
+ # Unlike other NavigableString subclasses, a DOCTYPE always ends
+ # in a newline.
+ doctype = Doctype("foo")
+ soup = self.soup("")
+ soup.insert(1, doctype)
+ self.assertEqual(soup.encode(), b"<!DOCTYPE foo>\n")
+