From 37f53a378ddab1c67a54448bb87cb61b5e122a44 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Mon, 3 Jun 2013 11:38:23 -0400 Subject: 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. --- bs4/tests/test_tree.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bs4/tests/test_tree.py') 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." -- cgit v1.2.3