Changeset 2848:46e363cae72d in livinglogic.python.xist

Show
Ignore:
Timestamp:
08/03/07 16:24:55 (12 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Add test for proper handling of style attributes in html.applycss().

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • test/test_html.py

    r2847 r2848  
    4141 
    4242 
    43  
    4443def test_applycss3(): 
    4544    with html.html() as e: 
     
    5352    assert str(e.walknode(html.p)[0].attrs.style) == "color: red;" 
    5453    assert list(e.walknode(html.style)) == [] 
     54 
     55 
     56def test_applycss4(): 
     57    with html.html() as e: 
     58        with html.head(): 
     59            +html.style("#id42 {color: red;}", type="text/css") 
     60        with html.body(): 
     61            +html.p("gurk", id="id42", style="color: blue;") 
     62 
     63    html.applycss(e) 
     64 
     65    # style attribute wins (same specificity, but it is considered to come last) 
     66    assert str(e.walknode(html.p)[0].attrs.style) == "color: blue;" 
     67    assert list(e.walknode(html.style)) == [] 
     68 
     69 
     70def test_applycss4(): 
     71    with html.html() as e: 
     72        with html.head(): 
     73            +html.style("p#id42 {color: red;}", type="text/css") 
     74        with html.body(): 
     75            +html.p("gurk", id="id42", style="color: blue;") 
     76 
     77    html.applycss(e) 
     78 
     79    # stylesheet wins (because element name + id has a greater specificity) 
     80    assert str(e.walknode(html.p)[0].attrs.style) == "color: red;" 
     81    assert list(e.walknode(html.style)) == []