From 2f72913160bedb509a8042693328d139e7c6b945 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Thu, 23 Feb 2012 11:16:45 -0500 Subject: Namespaced attributes are equal if they correspond to the same string. --- bs4/tests/test_soup.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'bs4/tests/test_soup.py') diff --git a/bs4/tests/test_soup.py b/bs4/tests/test_soup.py index 2b7c003..e9aaa78 100644 --- a/bs4/tests/test_soup.py +++ b/bs4/tests/test_soup.py @@ -3,7 +3,10 @@ import unittest from bs4 import BeautifulSoup -from bs4.element import SoupStrainer +from bs4.element import ( + SoupStrainer, + NamespacedAttribute, + ) from bs4.dammit import EntitySubstitution, UnicodeDammit from bs4.testing import SoupTest import warnings @@ -233,3 +236,17 @@ class TestUnicodeDammit(unittest.TestCase): msg = w[0].message self.assertTrue(isinstance(msg, UnicodeWarning)) self.assertTrue("Some characters could not be decoded" in str(msg)) + + +class TestNamedspacedAttribute(SoupTest): + + def test_attribute_is_equivalent_to_colon_separated_string(self): + a = NamespacedAttribute("a", "b") + self.assertEqual("a:b", a) + + def test_attributes_are_equivalent_if_all_members_identical(self): + a = NamespacedAttribute("a", "b", "c") + b = NamespacedAttribute("a", "b", "c") + self.assertEqual(a, b) + b.namespace = "d" + self.assertNotEqual(a, b) -- cgit v1.2.3