"""Test attribute selectors.""" from .. import util class TestAttribute(util.TestCase): """Test attribute selectors.""" MARKUP = """
""" def test_attribute_begins(self): """Test attribute whose value begins with the specified value.""" self.assert_selector( self.MARKUP, "[class^=here]", ["0"], flags=util.HTML ) def test_attribute_end(self): """Test attribute whose value ends with the specified value.""" self.assert_selector( self.MARKUP, "[class$=words]", ["0"], flags=util.HTML ) def test_attribute_contains(self): """Test attribute whose value contains the specified value.""" markup = """ """ self.assert_selector( markup, "[class*=words]", ["0", "3", "pre"], flags=util.HTML ) def test_attribute_contains_with_newlines(self): """Test attribute `*=` will match with new lines.""" self.assert_selector( "foo1foo1
", "span[title*='bar']", ["1", "2"], flags=util.HTML ) def test_attribute_starts_with_newlines(self): """Test attribute `^=` will match with new lines.""" self.assert_selector( "foo1foo1
", "span[title^='foo']", ["1", "2"], flags=util.HTML ) def test_attribute_ends_with_newlines(self): """Test attribute `$=` will match with new lines.""" self.assert_selector( "foo1foo1
", "span[title$='bar']", ["1", "2"], flags=util.HTML ) def test_attribute_dash_list_with_newlines(self): """Test attribute `|=` will match with new lines.""" self.assert_selector( "foo1foo1
", "span[title|='fo']", ["1", "2"], flags=util.HTML ) def test_attribute_space_list_with_newlines(self): """Test attribute `~=` will match with new lines.""" self.assert_selector( "foo1foo1
", "span[title~='baz']", ["1", "2"], flags=util.HTML )