summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAndrew Dalke <dalke@dalkescientific.com>2006-05-25 16:30:52 (GMT)
committerAndrew Dalke <dalke@dalkescientific.com>2006-05-25 16:30:52 (GMT)
commit2bddcbf10ed5fa0142a95f4e5d66acda355bf9e4 (patch)
tree78243d57e662bd0707b720eb67db2c0a23edf6e6 /Lib
parent1d2576dbf07e50242cb8eb2362e2289691e80915 (diff)
downloadcpython-2bddcbf10ed5fa0142a95f4e5d66acda355bf9e4.zip
cpython-2bddcbf10ed5fa0142a95f4e5d66acda355bf9e4.tar.gz
cpython-2bddcbf10ed5fa0142a95f4e5d66acda355bf9e4.tar.bz2
Added tests for implementation error we came up with in the need for speed sprint.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/string_tests.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index 3a5fbfe..f76a9eb 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