Skip to content

Commit

Permalink
Update test to accommodate change in error and use SelectorSyntaxError
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed Jul 10, 2024
1 parent b2d2863 commit 18f3302
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions soupsieve/css_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,11 @@ def parse_pseudo_class(
m.start(0)
)
else:
raise ValueError(
raise SelectorSyntaxError(
f"'{pseudo}' was detected as a pseudo-class and is either unsupported or invalid. "
"If the syntax was not intended to be recognized as a pseudo-class, please escape the colon."
"If the syntax was not intended to be recognized as a pseudo-class, please escape the colon.",
self.pattern,
m.start(0)
)

return has_selector, is_html
Expand Down
5 changes: 3 additions & 2 deletions tests/test_level1/test_pseudo_class.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Test general pseudo-class cases."""
from .. import util
from soupsieve import SelectorSyntaxError


class TestPseudoClass(util.TestCase):
Expand All @@ -8,9 +9,9 @@ class TestPseudoClass(util.TestCase):
def test_pseudo_class_not_implemented(self):
"""Test pseudo-class that is not implemented."""

self.assert_raises(':not-implemented', NotImplementedError)
self.assert_raises(':not-implemented', SelectorSyntaxError)

def test_unrecognized_pseudo(self):
"""Test unrecognized pseudo class."""

self.assert_raises(':before', NotImplementedError)
self.assert_raises(':before', SelectorSyntaxError)

0 comments on commit 18f3302

Please sign in to comment.