コード例 #1
0
ファイル: test_premailer.py プロジェクト: sowink/premailer
def test_merge_styles_basic():
    old = 'font-size:1px; color: red'
    new = 'font-size:2px; font-weight: bold'
    expect = 'color:red;', 'font-size:2px;', 'font-weight:bold'
    result = _merge_styles(old, new)
    for each in expect:
        assert each in result
コード例 #2
0
ファイル: test_premailer.py プロジェクト: revolunet/premailer
def test_merge_styles_basic():
    old = 'font-size:1px; color: red'
    new = 'font-size:2px; font-weight: bold'
    expect = 'color:red;', 'font-size:2px;', 'font-weight:bold'
    result = _merge_styles(old, new)
    for each in expect:
        assert each in result
コード例 #3
0
ファイル: test_premailer.py プロジェクト: sowink/premailer
def test_merge_styles_with_class():
    old = 'color:red; font-size:1px;'
    new, class_ = 'font-size:2px; font-weight: bold', ':hover'

    # because we're dealing with dicts (random order) we have to
    # test carefully.
    # We expect something like this:
    #  {color:red; font-size:1px} :hover{font-size:2px; font-weight:bold}

    result = _merge_styles(old, new, class_)
    assert result.startswith('{')
    assert result.endswith('}')
    assert ' :hover{' in result
    split_regex = re.compile('{([^}]+)}')
    assert len(split_regex.findall(result)) == 2
    expect_first = 'color:red', 'font-size:1px'
    expect_second = 'font-weight:bold', 'font-size:2px'
    for each in expect_first:
        assert each in split_regex.findall(result)[0]
    for each in expect_second:
        assert each in split_regex.findall(result)[1]
コード例 #4
0
ファイル: test_premailer.py プロジェクト: revolunet/premailer
def test_merge_styles_with_class():
    old = 'color:red; font-size:1px;'
    new, class_ = 'font-size:2px; font-weight: bold', ':hover'

    # because we're dealing with dicts (random order) we have to
    # test carefully.
    # We expect something like this:
    #  {color:red; font-size:1px} :hover{font-size:2px; font-weight:bold}

    result = _merge_styles(old, new, class_)
    ok_(result.startswith('{'))
    ok_(result.endswith('}'))
    ok_(' :hover{' in result)
    split_regex = re.compile('{([^}]+)}')
    eq_(len(split_regex.findall(result)), 2)
    expect_first = 'color:red', 'font-size:1px'
    expect_second = 'font-weight:bold', 'font-size:2px'
    for each in expect_first:
        ok_(each in split_regex.findall(result)[0])
    for each in expect_second:
        ok_(each in split_regex.findall(result)[1])