Python unittest

since 2011-07-18

python で UnitTest を使いたい。できれば日本語の文字列比較をして、Windows コマンドプロンプトで、エラーも日本語で表示したい。

http://docs.python.org/library/unittest.html

import unittest
 
class TestSequenceFunctions(unittest.TestCase):
	def test_braille(self):
		self.assertEqual(japanese_braille_translate(u"広い海を泳ぐ小さい魚。"),
			u"ヒロイ ウミヲ オヨグ チーサイ サカナ。")
 
if __name__ == "__main__":
	unittest.main()

残念ながら下記のような結果:

F
======================================================================
FAIL: test_braille (__main__.TestSequenceFunctions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "nvdajptext/translateTest.py", line 21, in test_braille
    u"繝偵Ο繧、 繧ヲ繝溘Υ 繧ェ繝ィ繧ー 繝√・繧オ繧、 繧オ繧ォ繝翫€・)
AssertionError: u'\u30d2\u30ed\u30a4 \u30a6\u30df \u30f2 \u30aa\u30e8\u30b0 \u30
c1\u30fc\u30b5\u [truncated]... != u'\u30d2\u30ed\u30a4 \u30a6\u30df\u30f2 \u30a
a\u30e8\u30b0 \u30c1\u30fc\u30b5\u3 [truncated]...
- \u30d2\u30ed\u30a4 \u30a6\u30df \u30f2 \u30aa\u30e8\u30b0 \u30c1\u30fc\u30b5\u
30a4 \u30b5\u30ab\u30ca \u3002
?       -              -
+ \u30d2\u30ed\u30a4 \u30a6\u30df\u30f2 \u30aa\u30e8\u30b0 \u30c1\u30fc\u30b5\u3
0a4 \u30b5\u30ab\u30ca\u3002


----------------------------------------------------------------------
Ran 1 test in 0.022s

FAILED (failures=1)

python_unittest.txt · 最終更新: 2011/07/18 19:39 by Takuya Nishimoto
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0