[kupfer] kupferstring: use setdefaultencoding in testing code



commit 223e0b535f8180747d23eafd9f16117ebc624d8f
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sun Sep 13 01:45:22 2009 +0200

    kupferstring: use setdefaultencoding in testing code
    
    For doctests to work correctly, we use a hack to set the default
    encoding when running the doctests.

 kupfer/kupferstring.py |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/kupfer/kupferstring.py b/kupfer/kupferstring.py
index 017bd7d..2378c0b 100644
--- a/kupfer/kupferstring.py
+++ b/kupfer/kupferstring.py
@@ -55,14 +55,16 @@ def tofolded(ustr):
 
 	Characters from other scripts are not transliterated.
 
-	>>> tofolded(u"á¼?λλάÏ?") == u"Î?λλαÏ?"
-	True
-
-	(These doctests pass, but should they fail, they fail hard)
+	>>> print tofolded(u"á¼?λλάÏ?")
+	Î?λλαÏ?
 	"""
 	srcstr = normalize("NFKD", ustr.translate(folding_table))
 	return u"".join(c for c in srcstr if category(c) != 'Mn')
 
 if __name__ == '__main__':
+	import sys
+	reload(sys)
+	sys.setdefaultencoding("UTF-8")
+
 	import doctest
 	doctest.testmod()



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