veekun_pokedex/pokedex/tests/test_roomaji.py
Andrew Ekstedt 0094e9584c Modernize our use of py.test
This commit updates the tests to take advantage of some of py.test's
newer features.  Requires py.test 2.3 or newer.  Tested with 2.3.0 and
2.5.2.

Tests which were parametrized now use py.test's built-in
parametrization[1].

The session and lookup objects are now implemented as fixtures[2].
The media root is a fixture as well.  Fixtures are automatically passed
to any function that expects them.

Since the session is now created in one place, it is now possible to
provide an engine URI on the command line when running py.test.  Ditto
for the index directory.  (But the environment variables still work of
course.)

Slow tests are now marked as such and not run unless the --all option is
given.

A couple media tests are marked as xfail (expected to fail) because they
are broken.

[1]: http://pytest.org/latest/parametrize.html
[2]: http://pytest.org/latest/fixture.html
2014-07-06 21:45:05 -07:00

60 lines
1.6 KiB
Python

# encoding: utf8
import pytest
parametrize = pytest.mark.parametrize
import pokedex.roomaji
@parametrize(
('kana', 'roomaji'),
[
(u'ヤミカラス', 'yamikarasu'),
# Elongated vowel
(u'イーブイ', 'iibui'),
(u'ホーホー', 'hoohoo'),
(u'ピカチュウ', u'pikachuu'),
# Combined characters
(u'ニャース', 'nyaasu'),
(u'ジャ', 'ja'),
(u'ぎゃくてん', 'gyakuten'),
(u'ウェザーボール', 'wezaabooru'),
# Special katakana combinations
(u'ラティアス', 'ratiasu'),
(u'ウィー', 'wii'),
(u'セレビィ', 'sereby'),
]
)
def test_roomaji(kana, roomaji):
result = pokedex.roomaji.romanize(kana)
assert result == roomaji
@parametrize(
('kana', 'roomaji'),
[
(u'ヤミカラス', u'jamikarasu'),
# Elongated vowel
(u'イーブイ', u'íbui'),
(u'ホーホー', u'hóhó'),
(u'ピカチュウ', u'pikačú'),
# Combined characters
(u'ニャース', u'ňjásu'),
(u'ジャ', u'dža'),
(u'ぎゃくてん', u'gjakuten'),
(u'ウェザーボール', u'wezábóru'),
# Special katakana combinations
(u'ラティアス', u'ratiasu'),
(u'ウィー', u''),
(u'セレビィ', u'serebí'),
]
)
def test_roomaji_cs(kana, roomaji):
result = pokedex.roomaji.romanize(kana, 'cs')
assert result == roomaji