[Python-checkins] r46221 - python/trunk/Lib/test/string_tests.py

andrew.dalke python-checkins at python.org
Thu May 25 18:30:53 CEST 2006


Author: andrew.dalke
Date: Thu May 25 18:30:52 2006
New Revision: 46221

Modified:
   python/trunk/Lib/test/string_tests.py
Log:
Added tests for implementation error we came up with in the need for speed sprint.


Modified: python/trunk/Lib/test/string_tests.py
==============================================================================
--- python/trunk/Lib/test/string_tests.py	(original)
+++ python/trunk/Lib/test/string_tests.py	Thu May 25 18:30:52 2006
@@ -882,6 +882,25 @@
                 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


More information about the Python-checkins mailing list