MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_removeprefix

Function test_removeprefix

extra_tests/snippets/builtin_str.py:720–749  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

718
719# remove*fix test
720def test_removeprefix():
721 s = "foobarfoo"
722 s_ref = "foobarfoo"
723 assert s.removeprefix("f") == s_ref[1:]
724 assert s.removeprefix("fo") == s_ref[2:]
725 assert s.removeprefix("foo") == s_ref[3:]
726
727 assert s.removeprefix("") == s_ref
728 assert s.removeprefix("bar") == s_ref
729 assert s.removeprefix("lol") == s_ref
730 assert s.removeprefix("_foo") == s_ref
731 assert s.removeprefix("-foo") == s_ref
732 assert s.removeprefix("afoo") == s_ref
733 assert s.removeprefix("*foo") == s_ref
734
735 assert s == s_ref, "undefined test fail"
736
737 s_uc = "😱foobarfoo🖖"
738 s_ref_uc = "😱foobarfoo🖖"
739 assert s_uc.removeprefix("😱") == s_ref_uc[1:]
740 assert s_uc.removeprefix("😱fo") == s_ref_uc[3:]
741 assert s_uc.removeprefix("😱foo") == s_ref_uc[4:]
742
743 assert s_uc.removeprefix("🖖") == s_ref_uc
744 assert s_uc.removeprefix("foo") == s_ref_uc
745 assert s_uc.removeprefix(" ") == s_ref_uc
746 assert s_uc.removeprefix("_😱") == s_ref_uc
747 assert s_uc.removeprefix(" 😱") == s_ref_uc
748 assert s_uc.removeprefix("-😱") == s_ref_uc
749 assert s_uc.removeprefix("#😱") == s_ref_uc
750
751
752def test_removeprefix_types():

Callers

nothing calls this directly

Calls 1

removeprefixMethod · 0.45

Tested by

no test coverage detected