summaryrefslogtreecommitdiff
path: root/bs4/tests/test_tree.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2013-05-20 11:45:08 -0400
committerLeonard Richardson <leonardr@segfault.org>2013-05-20 11:45:08 -0400
commitb289252da31f1824ee9c85f1ce53907069d6dd7e (patch)
treebfc6115d76306aa871ad157142314049809d2748 /bs4/tests/test_tree.py
parent612922241894abf0467e77c12fc4bb8aa130ac41 (diff)
A NavigableString object now has an immutable '.name' property whose
value is always None. This makes it easier to iterate over a mixed list of tags and strings without having to check whether each element is a tag or a string.
Diffstat (limited to 'bs4/tests/test_tree.py')
-rw-r--r--bs4/tests/test_tree.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py
index c39b3f7..fc0e2c6 100644
--- a/bs4/tests/test_tree.py
+++ b/bs4/tests/test_tree.py
@@ -1187,6 +1187,12 @@ class TestElementObjects(SoupTest):
soup = self.soup("foo<!--IGNORE-->bar")
self.assertEqual(['foo', 'bar'], list(soup.strings))
+ def test_string_has_immutable_name_property(self):
+ string = self.soup("s").string
+ self.assertEqual(None, string.name)
+ def t():
+ string.name = 'foo'
+ self.assertRaises(AttributeError, t)
class TestCDAtaListAttributes(SoupTest):