Пример #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)
Пример #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')
Пример #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'
Пример #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'
Пример #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"
Пример #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"