diff options
author | Leonard Richardson <leonardr@segfault.org> | 2018-12-30 21:13:03 -0500 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2018-12-30 21:13:03 -0500 |
commit | b514575d5fb99b20e826009213605c2840ee6b07 (patch) | |
tree | df4402d0879aa25ee7c04cec14445689b5366811 /bs4/testing.py | |
parent | 35668fff221abe596439c8950747ae1cffc8e21e (diff) |
Fixed a problem with multi-valued attributes where the value
contained whitespace. Thanks to Jens Svalgaard for the
fix. [bug=1787453]
Diffstat (limited to 'bs4/testing.py')
-rw-r--r-- | bs4/testing.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/bs4/testing.py b/bs4/testing.py index 9598f31..e4a0ffe 100644 --- a/bs4/testing.py +++ b/bs4/testing.py @@ -452,6 +452,18 @@ Hello, world! "<tbody><tr><td>Bar</td></tr></tbody>" "<tfoot><tr><td>Baz</td></tr></tfoot></table>") + def test_multivalued_attribute_with_whitespace(self): + # Whitespace separating the values of a multi-valued attribute + # should be ignored. + + markup = '<div class=" foo bar "></a>' + soup = self.soup(markup) + self.assertEqual(['foo', 'bar'], soup.div['class']) + + # If you search by the literal name of the class it's like the whitespace + # wasn't there. + self.assertEqual(soup.div, soup.find('div', class_="foo bar")) + def test_deeply_nested_multivalued_attribute(self): # html5lib can set the attributes of the same tag many times # as it rearranges the tree. This has caused problems with |