[kupfer] kupferstring: Doctest for non-destructive folding



commit d4bc770bf295ba028dd31de28a3579a65f3111ec
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sat Sep 12 21:15:29 2009 +0200

    kupferstring: Doctest for non-destructive folding
    
    A doctest to show that when strings that we do not transliterate to
    basic latin, pass through unharmed (accents removed).

 kupfer/kupferstring.py |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/kupfer/kupferstring.py b/kupfer/kupferstring.py
index 95d3807..017bd7d 100644
--- a/kupfer/kupferstring.py
+++ b/kupfer/kupferstring.py
@@ -42,9 +42,9 @@ def toutf8(ustr):
 	return ustr.encode("UTF-8", "replace")
 
 def tofolded(ustr):
-	u"""`Fold' @ustr
+	u"""Fold @ustr
 
-	Return a unicode str where composed characters are replaced by
+	Return a unicode string where composed characters are replaced by
 	their base, and extended latin characters are replaced by
 	similar basic latin characters.
 
@@ -52,6 +52,13 @@ def tofolded(ustr):
 	u'Wylacz'
 	>>> tofolded(u"naïveté")
 	u'naivete'
+
+	Characters from other scripts are not transliterated.
+
+	>>> tofolded(u"á¼?λλάÏ?") == u"Î?λλαÏ?"
+	True
+
+	(These doctests pass, but should they fail, they fail hard)
 	"""
 	srcstr = normalize("NFKD", ustr.translate(folding_table))
 	return u"".join(c for c in srcstr if category(c) != 'Mn')



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]