Exemplo n.º 1
0
def test_ungettext():
    # No context
    a_singular = " one\t\r\n\nlight \n\n!\n"
    a_plural = " many\t\r\n\nlights \n\n!\n"
    p_singular = "you found a light!"
    p_plural = "you found a pile of lights!"
    eq_(p_singular, n_(a_singular, a_plural, 1))
    eq_(p_plural, n_(a_singular, a_plural, 3))

    # With a context
    a_singular = "%d \n\n\tpoodle please"
    a_plural = "%d poodles\n\n\t please\n\n\n"
    p_singular_1 = "%d poodle (context=1)"
    p_plural_1 = "%d poodles (context=1)"
    p_singular_2 = "%d poodle (context=2)"
    p_plural_2 = "%d poodles (context=2)"
    eq_(p_singular_1, n_(a_singular, a_plural, 1, "context_one"))
    eq_(p_plural_1, n_(a_singular, a_plural, 3, "context_one"))
    eq_(p_singular_2, n_(a_singular, a_plural, 1, "context_two"))
    eq_(p_plural_2, n_(a_singular, a_plural, 3, "context_two"))
Exemplo n.º 2
0
def test_ungettext():
    # No context
    a_singular = " one\t\r\n\nlight \n\n!\n"
    a_plural = " many\t\r\n\nlights \n\n!\n"
    p_singular = "you found a light!"
    p_plural = "you found a pile of lights!"
    eq_(p_singular, n_(a_singular, a_plural, 1))
    eq_(p_plural, n_(a_singular, a_plural, 3))

    # With a context
    a_singular = "%d \n\n\tpoodle please"
    a_plural = "%d poodles\n\n\t please\n\n\n"
    p_singular_1 = "%d poodle (context=1)"
    p_plural_1 = "%d poodles (context=1)"
    p_singular_2 = "%d poodle (context=2)"
    p_plural_2 = "%d poodles (context=2)"
    eq_(p_singular_1, n_(a_singular, a_plural, 1, 'context_one'))
    eq_(p_plural_1, n_(a_singular, a_plural, 3, 'context_one'))
    eq_(p_singular_2, n_(a_singular, a_plural, 1, 'context_two'))
    eq_(p_plural_2, n_(a_singular, a_plural, 3, 'context_two'))
Exemplo n.º 3
0
def test_ungettext_not_found():
    eq_("yo", n_("yo", "yos", 1, "context"))
    eq_("yo yo", n_("  yo  yo  ", "yos", 1, "context"))
    eq_("yos", n_("yo", "yos", 3, "context"))
    eq_("yo yos", n_("yo", "  yo  yos  ", 3, "context"))
Exemplo n.º 4
0
def test_ungettext_not_found():
    eq_('yo', n_('yo', 'yos', 1, 'context'))
    eq_('yo yo', n_('  yo  yo  ', 'yos', 1, 'context'))
    eq_('yos', n_('yo', 'yos', 3, 'context'))
    eq_('yo yos', n_('yo', '  yo  yos  ', 3, 'context'))
Exemplo n.º 5
0
def test_ungettext_not_found():
    eq_('yo', n_('yo', 'yos', 1, 'context'))
    eq_('yo yo', n_('  yo  yo  ', 'yos', 1, 'context'))
    eq_('yos', n_('yo', 'yos', 3, 'context'))
    eq_('yo yos', n_('yo', '  yo  yos  ', 3, 'context'))