Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8462573

Browse files
committed
Marc-Andre Lemburg <[email protected]>:
Fixed some tests to not cause the script to fail, but rather output a warning (which then is caught by regrtest.py as wrong output). This is needed to make test_unicode.py run through on JPython. Thanks to Finn Bock.
1 parent 7ebb92e commit 8462573

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

Lib/test/test_unicode.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,18 @@ def __init__(self): self.seq = [7, u'hello', 123L]
251251
assert u"%c" % ("a",) == u'a'
252252
assert u"%c" % (34,) == u'"'
253253
assert u"%c" % (36,) == u'$'
254-
assert u"%r, %r" % (u"abc", "abc") == u"u'abc', 'abc'"
254+
value = u"%r, %r" % (u"abc", "abc")
255+
if value != u"u'abc', 'abc'":
256+
print '*** formatting failed for "%s"' % 'u"%r, %r" % (u"abc", "abc")'
257+
255258
assert u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def'
256-
assert u"%(x)s, %(ä)s" % {'x':u"abc", u'ä'.encode('utf-8'):"def"} == u'abc, def'
259+
try:
260+
value = u"%(x)s, %(ä)s" % {'x':u"abc", u'ä'.encode('utf-8'):"def"}
261+
except KeyError:
262+
print '*** formatting failed for "%s"' % "u'abc, def'"
263+
else:
264+
assert value == u'abc, def'
265+
257266
# formatting jobs delegated from the string implementation:
258267
assert '...%(foo)s...' % {'foo':u"abc"} == u'...abc...'
259268
assert '...%(foo)s...' % {'foo':"abc"} == '...abc...'
@@ -268,7 +277,7 @@ def __init__(self): self.seq = [7, u'hello', 123L]
268277
except ValueError:
269278
pass
270279
else:
271-
raise AssertionError, "'...%s...äöü...' % u'abc' failed to raise an exception"
280+
print "*** formatting failed ...%s...äöü...' % u'abc' failed to raise an exception"
272281
print 'done.'
273282

274283
# Test builtin codecs

0 commit comments

Comments
 (0)