Esempio n. 1
0
def test_insert_bad_type():
    s = HTMLFragment(
        '<strong>Vincent:</strong> Royale with cheese. '
        '<!-- Quarter Pounder -->'
    )
    with pytest.raises(TypeError):
        s.insert(0, 42)
Esempio n. 2
0
def test_insert_multi_chars():
    s = HTMLFragment(
        '<strong>Vincent:</strong> Royale with cheese. '
        '<!-- Quarter Pounder -->'
    )
    with pytest.raises(ValueError):
        s.insert(0, 'Jules')
Esempio n. 3
0
def test_insert_no_chars():
    s = HTMLFragment(
        '<strong>Vincent:</strong> Royale with cheese. '
        '<!-- Quarter Pounder -->'
    )
    s.insert(0, '')
    assert unicode(s) == (
        '<strong>Vincent:</strong> Royale with cheese. '
        '<!-- Quarter Pounder -->'
    )
    assert s[0] == 'V'
Esempio n. 4
0
def test_insert_text_by_index():
    s = HTMLFragment(
        '<strong>Vincent:</strong> Royale with cheese. '
        '<!-- Quarter Pounder -->'
    )
    s.insert(7, 's')
    assert unicode(s) == (
        '<strong>Vincents:</strong> Royale with cheese. '
        '<!-- Quarter Pounder -->'
    )
    assert s[7] == 's'
Esempio n. 5
0
def test_insert_no_chars():
    s = HTMLFragment("<strong>Vincent:</strong> Royale with cheese. " "<!-- Quarter Pounder -->")
    s.insert(0, "")
    assert unicode(s) == ("<strong>Vincent:</strong> Royale with cheese. " "<!-- Quarter Pounder -->")
    assert s[0] == "V"
Esempio n. 6
0
def test_insert_text_by_index():
    s = HTMLFragment("<strong>Vincent:</strong> Royale with cheese. " "<!-- Quarter Pounder -->")
    s.insert(7, "s")
    assert unicode(s) == ("<strong>Vincents:</strong> Royale with cheese. " "<!-- Quarter Pounder -->")
    assert s[7] == "s"