How to use the soupsieve.SelectorSyntaxError function in soupsieve

To help you get started, we’ve selected a few soupsieve examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facelessuser / soupsieve / tests / test_level1 / test_type.py View on Github external
def test_invalid_syntax(self):
        """Test invalid syntax."""

        self.assert_raises('div?', SelectorSyntaxError)
        self.assert_raises('-', SelectorSyntaxError)
github facelessuser / soupsieve / tests / test_level1 / test_list.py View on Github external
def test_invalid_double_comma(self):
        """Test that selectors cannot have double combinators."""

        self.assert_raises('div,, a', SelectorSyntaxError)
github facelessuser / soupsieve / tests / test_api.py View on Github external
def test_simple_syntax_error(self):
        """Test a simple syntax error (no context)."""

        with self.assertRaises(sv.SelectorSyntaxError) as cm:
            raise sv.SelectorSyntaxError('Syntax Message')

        e = cm.exception
        self.assertEqual(e.context, None)
        self.assertEqual(e.line, None)
        self.assertEqual(e.col, None)
        self.assertEqual(str(e), 'Syntax Message')
github facelessuser / soupsieve / tests / test_level4 / test_has.py View on Github external
def test_invalid_incomplete_has(self):
        """Test `:has()` fails with just a combinator."""

        self.assert_raises(':has(>)', SelectorSyntaxError)
github facelessuser / soupsieve / tests / test_level4 / test_attribute.py View on Github external
def test_attribute_forced_case_needs_value(self):
        """Test attribute value case insensitivity requires a value."""

        self.assert_raises('[id i]', SelectorSyntaxError)
github facelessuser / soupsieve / tests / test_level4 / test_is.py View on Github external
def test_invalid_pseudo_class_start_combinator(self):
        """Test invalid start combinator in pseudo-classes other than `:has()`."""

        self.assert_raises(':is(> div)', SelectorSyntaxError)
        self.assert_raises(':is(div, > div)', SelectorSyntaxError)
github facelessuser / soupsieve / tests / test_level1 / test_class.py View on Github external
def test_malformed_class(self):
        """Test malformed class."""

        # Malformed class
        self.assert_raises('td.+#some-id', SelectorSyntaxError)
github facelessuser / soupsieve / tests / test_extra / test_custom.py View on Github external
def test_custom_dependency_recursion(self):
        """Test that we fail on dependency recursion."""

        custom_selectors = {
            ":--parent-paragraph": "p:--parent",
            ":--parent": "p:--parent-paragraph"
        }

        self.assert_raises(':--parent', sv.SelectorSyntaxError, custom=custom_selectors)
github facelessuser / soupsieve / tests / test_level1 / test_list.py View on Github external
def test_invalid_start_comma(self):
        """Test that selectors cannot start with a comma."""

        self.assert_raises(', p', SelectorSyntaxError)
github facelessuser / soupsieve / tests / test_api.py View on Github external
def test_simple_syntax_error(self):
        """Test a simple syntax error (no context)."""

        with self.assertRaises(sv.SelectorSyntaxError) as cm:
            raise sv.SelectorSyntaxError('Syntax Message')

        e = cm.exception
        self.assertEqual(e.context, None)
        self.assertEqual(e.line, None)
        self.assertEqual(e.col, None)
        self.assertEqual(str(e), 'Syntax Message')