def test_insert_bad_type(): s = HTMLFragment( '<strong>Vincent:</strong> Royale with cheese. ' '<!-- Quarter Pounder -->' ) with pytest.raises(TypeError): s.insert(0, 42)
def test_insert_multi_chars(): s = HTMLFragment( '<strong>Vincent:</strong> Royale with cheese. ' '<!-- Quarter Pounder -->' ) with pytest.raises(ValueError): s.insert(0, 'Jules')
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'
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'
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"
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"