From: Andrew Dalke Date: Thu, 25 May 2006 16:30:52 +0000 (+0000) Subject: Added tests for implementation error we came up with in the need for speed sprint. X-Git-Tag: v2.5b1~538 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2bddcbf10ed5fa0142a95f4e5d66acda355bf9e4;p=python Added tests for implementation error we came up with in the need for speed sprint. --- diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index 3a5fbfefb5..f76a9ebe08 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -882,6 +882,25 @@ class MixinStrUnicodeUserStringTest: else: self.checkcall(format, "__mod__", value) + def test_inplace_rewrites(self): + # Check that strings don't copy and modify cached single-character strings + self.checkequal('a', 'A', 'lower') + self.checkequal(True, 'A', 'isupper') + self.checkequal('A', 'a', 'upper') + self.checkequal(True, 'a', 'islower') + + self.checkequal('a', 'A', 'replace', 'A', 'a') + self.checkequal(True, 'A', 'isupper') + + self.checkequal('A', 'a', 'capitalize') + self.checkequal(True, 'a', 'islower') + + self.checkequal('A', 'a', 'swapcase') + self.checkequal(True, 'a', 'islower') + + self.checkequal('A', 'a', 'title') + self.checkequal(True, 'a', 'islower') + class MixinStrStringUserStringTest: # Additional tests for 8bit strings, i.e. str, UserString and