Skip to content

Commit 8cc4a26

Browse files
committed
Lint
1 parent 97ab897 commit 8cc4a26

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

cssselect/parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ def parse_simple_selector(stream, inside_negation=False):
452452
continue
453453
if stream.peek() != ('DELIM', '('):
454454
result = Pseudo(result, ident)
455-
if result.ident == 'scope':
455+
if result.ident == 'scope' and repr(
456+
result) == 'Pseudo[Element[*]:scope]':
456457
if not (len(stream.used) == 2 or
457458
(len(stream.used) == 3
458459
and stream.used[0].type == 'S')):

tests/test_cssselect.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class TestCssselect(unittest.TestCase):
4242
def test_tokenizer(self):
4343
tokens = [
4444
_unicode(item) for item in tokenize(
45-
u(r'E\ é > f [a~="y\"x"]:nth(/* fu /]* */-3.7)<'))]
45+
u(r'E\ é > f [a~="y\"x"]:nth(/* fu /]* */-3.7)'))]
4646
assert tokens == [
4747
u("<IDENT 'E é' at 0>"),
4848
"<S ' ' at 4>",
@@ -61,8 +61,7 @@ def test_tokenizer(self):
6161
"<DELIM '(' at 24>",
6262
"<NUMBER '-3.7' at 37>",
6363
"<DELIM ')' at 41>",
64-
"<DELIM '<' at 42>",
65-
"<EOF at 43>",
64+
"<EOF at 42>",
6665
]
6766

6867
def test_parser(self):
@@ -162,7 +161,6 @@ def parse_many(first, *others):
162161
'Hash[Element[*]#foo]] <followed> Hash[Element[*]#bar]]'
163162
]
164163

165-
# TODO ADD TESTS
166164
def test_pseudo_elements(self):
167165
def parse_pseudo(css):
168166
result = []
@@ -334,6 +332,9 @@ def get_error(css):
334332
assert get_error(':scope > div :scope header') == (
335333
'Got immediate child pseudo-element ":scope" not at the start of a selector'
336334
)
335+
assert get_error('div :scope header') == (
336+
'Got immediate child pseudo-element ":scope" not at the start of a selector'
337+
)
337338
assert get_error('> div p') == ("Expected selector, got <DELIM '>' at 0>")
338339

339340
def test_translation(self):

0 commit comments

Comments
 (0)