summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2011-08-15 06:22:24 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2011-08-15 06:22:24 (GMT)
commit15d6b65ead4bc2cce509fe16decce311f1f1bd71 (patch)
treea82823880d5543f64d89d72c38c90339207df682 /Lib
parentca5e908c6ed5df85571f2cfe2a27533a780bfbe3 (diff)
downloadcpython-15d6b65ead4bc2cce509fe16decce311f1f1bd71.zip
cpython-15d6b65ead4bc2cce509fe16decce311f1f1bd71.tar.gz
cpython-15d6b65ead4bc2cce509fe16decce311f1f1bd71.tar.bz2
#12266: Fix str.capitalize() to correctly uppercase/lowercase titlecased and cased non-letter characters.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/string_tests.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index 5931f3d..9cf3345 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -96,6 +96,23 @@ class CommonTest(unittest.TestCase):
self.checkequal('Aaaa', 'aaaa', 'capitalize')
self.checkequal('Aaaa', 'AaAa', 'capitalize')
+ # check that titlecased chars are lowered correctly
+ # \u1ffc is the titlecased char
+ self.checkequal(u'\u1ffc\u1ff3\u1ff3\u1ff3',
+ u'\u1ff3\u1ff3\u1ffc\u1ffc', 'capitalize')
+ # check with cased non-letter chars
+ self.checkequal(u'\u24c5\u24e8\u24e3\u24d7\u24de\u24dd',
+ u'\u24c5\u24ce\u24c9\u24bd\u24c4\u24c3', 'capitalize')
+ self.checkequal(u'\u24c5\u24e8\u24e3\u24d7\u24de\u24dd',
+ u'\u24df\u24e8\u24e3\u24d7\u24de\u24dd', 'capitalize')
+ self.checkequal(u'\u2160\u2171\u2172',
+ u'\u2160\u2161\u2162', 'capitalize')
+ self.checkequal(u'\u2160\u2171\u2172',
+ u'\u2170\u2171\u2172', 'capitalize')
+ # check with Ll chars with no upper - nothing changes here
+ self.checkequal(u'\u019b\u1d00\u1d86\u0221\u1fb7',
+ u'\u019b\u1d00\u1d86\u0221\u1fb7', 'capitalize')
+
self.checkraises(TypeError, 'hello', 'capitalize', 42)
def test_count(self):