[Python-Dev] Known doctest bug with unicode? (original) (raw)
Jeroen Ruigrok van der Werven asmodai at in-nomine.org
Fri Apr 18 16:27:05 CEST 2008
- Previous message: [Python-Dev] Known doctest bug with unicode?
- Next message: [Python-Dev] Known doctest bug with unicode?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
vim: set fileencoding=utf-8 :
kanamap = { u'あ': 'a' }
def transpose(word): """Convert a word in kana to its equivalent Hepburn romanisation.
>>> transpose(u'あ')
'a'
"""
transposed = ''
for character in word:
transposed += kanamap[character]
return transposed
if name == 'main': import doctest doctest.testmod()
doctest:
[16:24] [ruigrok at akuma] (1) {20} % python trans.py
File "trans.py", line 11, in main.transpose Failed example: transpose(u'あ') Exception raised: Traceback (most recent call last): File "doctest.py", line 1212, in __run compileflags, 1) in test.globs File "<doctest __main__.transpose[0]>", line 1, in transpose(u'あ') File "trans.py", line 16, in transpose transposed += kanamap[character] KeyError: u'\xe3'
1 items had failures: 1 of 1 in main.transpose Test Failed 1 failures.
normal interpreter:
fromm trans import transpose transpose(u'あ') 'a'
-- Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai イェルーン ラウフロック ヴァン デル ウェルヴェン http://www.in-nomine.org/ | http://www.rangaku.org/ They have learned nothing, and forgotten nothing...
- Previous message: [Python-Dev] Known doctest bug with unicode?
- Next message: [Python-Dev] Known doctest bug with unicode?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]