@@ -426,7 +426,6 @@ def pcss(main, *selectors, **kwargs):
426
426
return result
427
427
428
428
all_ids = pcss ('*' )
429
- assert len (all_ids ) == 32
430
429
assert all_ids [:6 ] == [
431
430
'html' , 'nil' , 'link-href' , 'link-nohref' , 'nil' , 'outer-div' ]
432
431
assert all_ids [- 1 :] == ['foobar-span' ]
@@ -472,8 +471,7 @@ def pcss(main, *selectors, **kwargs):
472
471
assert pcss ('ol:nth-last-of-type(1)' ) == ['first-ol' ]
473
472
assert pcss ('span:only-child' ) == ['foobar-span' ]
474
473
assert pcss ('li div:only-child' ) == ['li-div' ]
475
- assert pcss ('div *:only-child' ) == [
476
- 'li-div' , 'checkbox-disabled' , 'foobar-span' ]
474
+ assert pcss ('div *:only-child' ) == ['li-div' , 'foobar-span' ]
477
475
self .assertRaises (ExpressionError , pcss , 'p *:only-of-type' )
478
476
self .assertRaises (ExpressionError , pcss , 'p:lang(fr)' )
479
477
assert pcss ('p:only-of-type' ) == ['paragraph' ]
@@ -504,25 +502,25 @@ def pcss(main, *selectors, **kwargs):
504
502
assert pcss ('ol#first-ol *:last-child' ) == ['li-div' , 'seventh-li' ]
505
503
assert pcss ('#outer-div:first-child' ) == ['outer-div' ]
506
504
assert pcss ('#outer-div :first-child' ) == [
507
- 'name-anchor' , 'first-li' , 'li-div' , 'p-b' , 'checkbox-disabled' ,
508
- 'area-href' ]
505
+ 'name-anchor' , 'first-li' , 'li-div' , 'p-b' ,
506
+ 'checkbox-fieldset-disabled' , ' area-href' ]
509
507
assert pcss ('a[href]' ) == ['tag-anchor' , 'nofollow-anchor' ]
508
+ assert pcss ('a:not([href])' ) == ['name-anchor' ]
509
+ assert pcss ('ol :Not(li[class])' ) == [
510
+ 'first-li' , 'second-li' , 'li-div' ,
511
+ 'fifth-li' , 'sixth-li' , 'seventh-li' ]
510
512
511
-
513
+ # HTML-specific
512
514
assert pcss (':link' , html_only = True ) == [
513
515
'link-href' , 'tag-anchor' , 'nofollow-anchor' , 'area-href' ]
514
516
assert pcss (':visited' , html_only = True ) == []
515
-
517
+ assert pcss (':enabled' , html_only = True ) == [
518
+ 'link-href' , 'tag-anchor' , 'nofollow-anchor' ,
519
+ 'checkbox-unchecked' , 'checkbox-checked' , 'area-href' ]
520
+ assert pcss (':disabled' , html_only = True ) == [
521
+ 'checkbox-disabled' , 'fieldset' , 'checkbox-fieldset-disabled' ]
516
522
517
523
assert pcss (':checked' , html_only = True ) == ['checkbox-checked' ]
518
- assert pcss (':disabled' , html_only = True ) == [
519
- 'fieldset' , 'checkbox-disabled' ]
520
- assert pcss (':enabled' , html_only = True ) == [
521
- 'checkbox-unchecked' , 'checkbox-checked' ]
522
- assert pcss ('a:not([href])' ) == ['name-anchor' ]
523
- assert pcss ('ol :Not(li[class])' ) == [
524
- 'first-li' , 'second-li' , 'li-div' ,
525
- 'fifth-li' , 'sixth-li' , 'seventh-li' ]
526
524
527
525
def test_select_shakespeare (self ):
528
526
document = html .document_fromstring (HTML_SHAKESPEARE )
@@ -624,9 +622,13 @@ def count(selector):
624
622
<b id="p-b">hi</b> <em id="p-em">there</em>
625
623
<b id="p-b2">guy</b>
626
624
<input type="checkbox" id="checkbox-unchecked" />
625
+ <input type="checkbox" id="checkbox-disabled" disabled="disabled" />
626
+ <input type="hidden" />
627
+ <input type="hidden" disabled="disabled" />
627
628
<input type="checkbox" id="checkbox-checked" checked="checked" />
628
629
<fieldset id="fieldset" disabled="disabled">
629
- <input type="checkbox" id="checkbox-disabled" />
630
+ <input type="checkbox" id="checkbox-fieldset-disabled" />
631
+ <input type="hidden" />
630
632
</fieldset>
631
633
</p>
632
634
<ol id="second-ol">
0 commit comments