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

Function test_removesuffix

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

Source from the content-addressed store, hash-verified

764
765
766def test_removesuffix():
767 s = "foobarfoo"
768 s_ref = "foobarfoo"
769 assert s.removesuffix("o") == s_ref[:-1]
770 assert s.removesuffix("oo") == s_ref[:-2]
771 assert s.removesuffix("foo") == s_ref[:-3]
772
773 assert s.removesuffix("") == s_ref
774 assert s.removesuffix("bar") == s_ref
775 assert s.removesuffix("lol") == s_ref
776 assert s.removesuffix("foo_") == s_ref
777 assert s.removesuffix("foo-") == s_ref
778 assert s.removesuffix("foo*") == s_ref
779 assert s.removesuffix("fooa") == s_ref
780
781 assert s == s_ref, "undefined test fail"
782
783 s_uc = "😱foobarfoo🖖"
784 s_ref_uc = "😱foobarfoo🖖"
785 assert s_uc.removesuffix("🖖") == s_ref_uc[:-1]
786 assert s_uc.removesuffix("oo🖖") == s_ref_uc[:-3]
787 assert s_uc.removesuffix("foo🖖") == s_ref_uc[:-4]
788
789 assert s_uc.removesuffix("😱") == s_ref_uc
790 assert s_uc.removesuffix("foo") == s_ref_uc
791 assert s_uc.removesuffix(" ") == s_ref_uc
792 assert s_uc.removesuffix("🖖_") == s_ref_uc
793 assert s_uc.removesuffix("🖖 ") == s_ref_uc
794 assert s_uc.removesuffix("🖖-") == s_ref_uc
795 assert s_uc.removesuffix("🖖#") == s_ref_uc
796
797
798def test_removesuffix_types():

Callers

nothing calls this directly

Calls 1

removesuffixMethod · 0.45

Tested by

no test coverage detected