summaryrefslogtreecommitdiff
path: root/bs4/tests/test_tree.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2013-06-03 11:38:23 -0400
committerLeonard Richardson <leonard.richardson@canonical.com>2013-06-03 11:38:23 -0400
commit37f53a378ddab1c67a54448bb87cb61b5e122a44 (patch)
treecf9fad56204fffdaaf1fa5c3982a0c627ee08057 /bs4/tests/test_tree.py
parentf5ff09d09ef6c60f5d5052fac25d4e128bdce34f (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 2d09f96..0acc092 100644
--- a/bs4/tests/test_tree.py
+++ b/bs4/tests/test_tree.py
@@ -1219,6 +1219,12 @@ class TestCDAtaListAttributes(SoupTest):
# attribute for any other tag.
self.assertEqual('ISO-8859-1 UTF-8', soup.a['accept-charset'])
+ 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 TestPersistence(SoupTest):
"Testing features like pickle and deepcopy."