[Zope-Checkins] CVS: Zope/lib/python/StructuredText/tests - testStructuredText.py:1.18.8.1
Florent Guillaume
fg@nuxeo.com
Mon, 16 Sep 2002 21:10:19 -0400
Update of /cvs-repository/Zope/lib/python/StructuredText/tests
In directory cvs.zope.org:/tmp/cvs-serv18502/tests
Modified Files:
Tag: Zope-2_6-i18n-branch
testStructuredText.py
Log Message:
Unicode fixes for StructuredText.
This makes the code run, but ST still uses the Zope locale to get
'letters', when it probably should use \w+ and re.U on any Unicode
strings. So currently non-ascii alphabetic Unicode characters in a stx
document are still treated as non-alphabetic.
=== Zope/lib/python/StructuredText/tests/testStructuredText.py 1.18 => 1.18.8.1 ===
--- Zope/lib/python/StructuredText/tests/testStructuredText.py:1.18 Wed Aug 14 17:58:23 2002
+++ Zope/lib/python/StructuredText/tests/testStructuredText.py Mon Sep 16 21:10:18 2002
@@ -18,6 +18,7 @@
from StructuredText import HTMLClass
from StructuredText.StructuredText import HTML
import sys, os, unittest, cStringIO
+from types import UnicodeType
from OFS import ndiff
"""
@@ -52,6 +53,8 @@
raw_text = readFile(regressions,f)
assert StructuredText.StructuredText(raw_text),\
'StructuredText failed on %s' % f
+ assert StructuredText.StructuredText(unicode(raw_text)),\
+ 'StructuredText failed on Unicode %s' % f
def testStructuredTextNG(self):
""" testing StructuredTextNG """
@@ -60,6 +63,8 @@
raw_text = readFile(regressions,f)
assert ST.StructuredText(raw_text),\
'StructuredText failed on %s' % f
+ assert ST.StructuredText(unicode(raw_text)),\
+ 'StructuredText failed on Unicode %s' % f
def testDocumentClass(self):
@@ -131,12 +136,25 @@
def _test(self,stxtxt , expected):
- res = HTML(stxtxt,level=1,header=0)
+ if not isinstance(stxtxt, UnicodeType):
+ res = HTML(stxtxt,level=1,header=0)
+ if res.find(expected)==-1:
+ print "Text: ",stxtxt
+ print "Converted:",res
+ print "Expected: ",expected
+ raise AssertionError,"basic test failed for '%s'" % stxtxt
+
+ if isinstance(stxtxt, UnicodeType):
+ ustxtxt = stxtxt
+ else:
+ ustxtxt = unicode(stxtxt)
+ res = HTML(ustxtxt,level=1,header=0)
if res.find(expected)==-1:
- print "Text: ",stxtxt
- print "Converted:",res
- print "Expected: ",expected
- raise AssertionError,"basic test failed for '%s'" % stxtxt
+ print "Text: ",stxtxt.encode('latin-1')
+ print "Converted:",res.encode('latin-1')
+ print "Expected: ",expected.encode('latin-1')
+ raise AssertionError, ("basic test failed for Unicode '%s'"
+ % stxtxt)
def testUnderline(self):
@@ -190,6 +208,14 @@
def testLinkInLiteral(self):
self._test("this is a '\"literal\":http://www.zope.org/.' eh",
'<code>"literal":http://www.zope.org/.</code>')
+
+
+ def XXXtestUnicodeContent(self):
+ # This fails because ST uses the default locale to get "letters"
+ # whereas it should use \w+ and re.U if the string is Unicode.
+ #self._test(u"h\xe9 **y\xe9** xx",
+ # u"h\xe9 <strong>y\xe9</strong> xx")
+ pass
def test_suite():